Iphone - can presentModalViewController do this in non-full screen mode?

I have a view controller, and I present it as modal, as in ...

UIViewController *myWindow = [[UIViewController alloc] init];
CGRect myFrame = CGRectMake(0.0f, 0.0f, 115.0f, 120.0f);
myWindow.view.frame = myFrame;

[self presentModalViewController:myWindow animated:YES];

Is there a way to transmit it not full screen in a certain size?

+3
source share
2 answers

There is no standard way to do this.

I faked it by using UIActionSheetand setting the view controller view as a subitem of the action sheet, and then dropping the borders of the action sheet. This is a rather strange hack, and I would not recommend it.

sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
sheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;

UIViewController *modalController = [[UIViewController alloc] initWithNibName:@"SomeNib" bundle:nil];

sheet.autoresizesSubviews = NO;
[sheet addSubview:modalController.view];
[sheet showInView:self.view];
[UIView beginAnimations:nil context:nil];
[sheet setBounds:CGRectMake(0, 0, 320, 728)];
[UIView commitAnimations];

The obvious drawbacks here are the uncontrolled events of the normal vision controller ( viewWillAppear:, viewDidAppear:etc.)

+3
source

, :)

IUView , . , , "" , .

+2

Source: https://habr.com/ru/post/1767202/


All Articles