开发者

Showing another view from delegate method

开发者 https://www.devze.com 2023-03-25 18:49 出处:网络
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 fr

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:(NSNumb开发者_运维百科er*)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^^


I didn't find any good method to do it, however when i added navigation controller and instead of:

[self presentModalViewController:dvController animated:YES]; 

used:

[self.navigationController pushViewController:pictureEditingVC animated:YES]; 

Application was working good. It isn't a solution but a way to omit this problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消