यहां एक समाधान है जिसका मैं उपयोग करता हूं। यह काफी कुछ नहीं है जो आप वर्णन करते हैं, जो भी साफ होगा, लेकिन यह मुश्किल होगा क्योंकि आप चाहते हैं कि बटन आंशिक रूप से दृश्य की सीमाओं से बाहर हो (जैसा कि आप कहते हैं, इसे दृश्य-नियंत्रक का बच्चा होना होगा- देखें पर्यवेक्षण)।
मेरा समाधान नेविगेशन बार के बाएं-बटन क्षेत्र में एक करीबी बटन डालना है। मैं इसे UIViewController क्लास एक्सटेंशन के माध्यम से स्वचालित रूप से करता हूं। इसका उपयोग करने के लिए, बस [currentViewController presentAutoModalViewController: modalViewController एनिमेटेड: YES] पर कॉल करें;
@implementation UIViewController (Modal)
- (void) presentAutoModalViewController: (UIViewController *) modalViewController withDismissAction: (SEL) onDismiss animated:(BOOL)animated
{
UINavigationController* nc = nil;
if (NO == [ modalViewController isKindOfClass: [UINavigationController class]])
{
nc = [[[UINavigationController alloc] initWithRootViewController: modalViewController] autorelease];
[nc setToolbarHidden:YES animated: NO];
nc.modalPresentationStyle = modalViewController.modalPresentationStyle;
modalViewController.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:onDismiss] autorelease];
}
else
{
nc = (UINavigationController*) modalViewController;
UIViewController* rootViewController = [nc.viewControllers objectAtIndex: 0];
rootViewController.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:onDismiss] autorelease];
}
[nc setNavigationBarHidden: NO];
nc.navigationBar.barStyle = UIBarStyleBlack;
nc.toolbar.barStyle = self.navigationController.navigationBar.barStyle;
[self presentModalViewController: nc animated: animated ];
}
- (void) presentAutoModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
{
[self presentAutoModalViewController:modalViewController withDismissAction: @selector(autoModalViewControllerDismiss:) animated: animated];
}
- (void) autoModalViewControllerDismiss: (id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL) isAutoModalViewController
{
return (self.navigationController != nil && self.navigationController.parentViewController != nil && self.navigationController.parentViewController.modalViewController == self.navigationController);
}
@end
क्या आप "पृष्ठ शीट में जोड़कर इसका हिस्सा छिपा कर देगा, क्योंकि यह दृश्य क्षेत्र से बाहर है।" से क्या मतलब है? –