![](/img/trans.png)
[英]Unable to listen notification from NSNotificationCenter when App received push notification from background or terminated in iOS
[英]How to change frame rect when received a notification from NSNotificationCenter?
我有一个带有按钮的视图,可以从相机拍摄图像。 当我按下捕获按钮时,它将重定向到另一个视图控制器。 拍照后,视图会弹出到上一个视图控制器。 弹出视图时,我还会将拍摄的图像发送到第一视图控制器的通知。 收到图像后,我尝试更改视图setFrame
方法的框架。 但是框架没有更新。 我试过的是
- (void) onReceiveImage:(NSNotification *) notification{
if ([[notification name] isEqualToString:@"ImageCapturedNotification"]) {
[self.postTxtView resignFirstResponder];
NSDictionary* userInfo = notification.userInfo;
UIImage *image = (UIImage*)userInfo[@"image"];
[self.postLandImageView setImage:image];
// in here i want to change the view frame
}
}
要改变我做的框架
self.bottomView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-self.bottomView.frame.size.width, self.view.bounds.size.height-self.bottomView.frame.size.height, self.bottomView.frame.size.width, self.bottomView.frame.size.height);
这是行不通的。 请帮我完成这个任务。 谢谢。
请检查您是否在主线程上执行代码。
在大多数情况下,仅在应用程序的主线程中使用UIKit类。 对于从UIResponder派生的类或涉及以任何方式操纵应用程序的用户界面的类而言,尤其如此。
dispatch_async(dispatch_get_main_queue(), ^{
// Do any setup on main queue
});
如果要在主线程上执行代码,可以提供示例演示吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.