显示委托方法的另一个视图
我有2个类:A类有一个声明的协议,我在B类中调用它。我使用委托将图像从A类发送到B类,并在B类中根据A类的协议方法对该图像执行一些操作。然后我想要在B类中的该协议方法的末尾创建新视图。我知道调用新视图的这两行代码正在工作,因为如果我在A类中调用它(例如在viewDidLoad中),那么它就可以工作。在这种情况下,新视图显示了我想要的一切。但是,当我从协议的方法调用它时,它不起作用。如何展示这个视图呢?
类 Ah
@protocol AViewControllerDelegate<NSObject>
@optional
- (void) tappedImage:(NSNumber*)tag;
@end
类 Am
[self dismissModalViewControllerAnimated:YES];
if ([self.delegatee respondsToSelector:@selector(tappedImage:)])
[self.delegatee performSelector:@selector(tappedImage:) withObject: [NSNumber numberWithInt:imageView.tag]];
类 Bm
- (void) tappedImage:(NSNumber*)tag{
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: [NSString stringWithFormat: @"%@.png",tag]]];
PictureEditingViewController *dvController = [[PictureEditingViewController alloc] initWithPicture: imgView.image];
[self presentModalViewController:dvController animated:YES];
//[dvController release]; dvController = nil;
}
PictureEditingViewController 被调用,我看到 NSLog 位于 viewDidLoad 中。然而,iPhone 屏幕上没有显示任何内容,可能新视图位于旧视图“下方”。 如何将新视图设置在旧视图的顶部..?
感谢您的帮助^^
I have 2 classes: class A have a declared protocol, which i call in class B. I send image from class A to class B using delegate and in class B do something with this image under method of protocol from class A. Then i want to make new view in the end of this protocol's method inside class B. I know tese 2 lines of invoking new view is working because if i call it in class A (eg in viewDidLoad) then it's working. New view is showing in this case everything i want. However when i call it from protocol's method it isn't working. How to show this view?
class A.h
@protocol AViewControllerDelegate<NSObject>
@optional
- (void) tappedImage:(NSNumber*)tag;
@end
class A.m
[self dismissModalViewControllerAnimated:YES];
if ([self.delegatee respondsToSelector:@selector(tappedImage:)])
[self.delegatee performSelector:@selector(tappedImage:) withObject: [NSNumber numberWithInt:imageView.tag]];
class B.m
- (void) tappedImage:(NSNumber*)tag{
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: [NSString stringWithFormat: @"%@.png",tag]]];
PictureEditingViewController *dvController = [[PictureEditingViewController alloc] initWithPicture: imgView.image];
[self presentModalViewController:dvController animated:YES];
//[dvController release]; dvController = nil;
}
PictureEditingViewController is called, i see NSLog which i have inside viewDidLoad there. However nothing is showing on iphone screen, probably the new view is 'under' the old view.
How to set the new view ON the top of the old view..?
Thanks for any help^^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有找到任何好的方法来做到这一点,但是当我添加导航控制器而不是:
使用:
应用程序运行良好。这不是一个解决方案,而是一种忽略这个问题的方法。
I didn't find any good method to do it, however when i added navigation controller and instead of:
used:
Application was working good. It isn't a solution but a way to omit this problem.