In Cocoa-Touch Framework, is there any modal view in iPad like this? - objective-c

Is there any model view like this on the iPad?

Yes, there is:
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered on the screen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
For example:
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:viewController animated:YES];
viewController.view.superview.frame = CGRectMake(0, 0, 540, 500); // this is important to do this after presentModalView
viewController.view.superview.center = self.view.superview.center;

Related

SafeArea in iOS 11: how add view on main screen with custom navigationBar without safeArea from code in objective-c

In my project on Objective-C mainScreen with Custom NavigationBar (created from code):
mainNavigationController = [[NavigationController alloc] initWithRootViewController:mainMenuViewController];
mainNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
mainNavigationController.delegate = self;
mainNavigationController.navigationBar.tintColor = [UIColor whiteColor];
UIWindow* window = self.window;
window.backgroundColor = [UIColor whiteColor];
window.rootViewController = mainNavigationController;
[window makeKeyAndVisible];
I change self.view like size [UIScreen mainScreen].applicationFrame]:
UIView* mainView = [[[MainViewControllerView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];
self.view = mainView;
In mainScreenView I add scrollView:
scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
scrollView.autoresizesSubviews = YES;
scrollView.autoresizingMask = UIViewAutoresizingNone;
scrollView.backgroundColor = [UIColor clearColor];
scrollView.bounces = NO;
And add some subView inside scrollView:
[scrollView addSubview:myLogoView];
[scrollView addSubview:littleScrollView];
[scrollView addSubview:firstButton];
[scrollView addSubview:secondButton];
[scrollView addSubview:thirdButton];
[scrollView addSubview:fouthButton];
[scrollView addSubview:fifthButton];
[scrollView addSubview:sixthButton];
[scrollView addSubview:seventhButton];
[scrollView addSubview:activityIndicatorView];
https://www.dropbox.com/s/ttrkolgnch80kr9/safeArea.png?dl=0
If use XCODE 8 and iOS <= 10, all view place correct on mainScreen (myLogoView place ignore size of custom NavigationBar and have coordinate Y == 20.0 in absolute value coordinates of device screen),
but if use XCode 9 and iOS 11 myLogoView have place under my custom navigationBar (height == 44) myLogoView Y == 64.0 in absolute value coordinates of device screen, in iOS 10 (under xCode9) all working good - added view on mainScreen placed in start coordinates of screen and ignore height of custom NavigationBar.
In swift and storyboard I know how it fixed in iOS11 easy remove safeArea top line, but how remove safeArea from code in Objective-C.
How fix this trouble?
Safe area in iOS 11 is replacement of top & bottom layout and apple provide more detail on this like below :
The layout guide representing the portion of your view that is
unobscured by bars and other content. In iOS 11, Apple is deprecating
the top and bottom layout guides and replacing them with a single safe
area layout guide.
So base on this now top & bottom layout replaced with single safe area but agin if you are not using default NavigationBar so you can disable safe area in storyboard like below :
You can Uncheck safe area and it will revert to top & bottom layout.
Ref Before & After uncheck safe area:
Before or default :
Uncheck Safe area or old behavior :
Hope this will help to understand new iOS 11 update related to top & bottom layout and change your code as per this layout change.
Also here is one good blog to explain more on Safe area layout : Safe area

How to programmaticaly add an UIActivityIndicatorView to a view on the bottom right corner

I'm trying to programmatically add and position an UIActivityIndicatorView to the bottom right corner of my main view. My app can rotate.
Right now in my viewDidLoad-method I have this code:
[super viewDidLoad];
UIActivityIndicatorView *iv = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[iv startAnimating];
int margin = 14;
iv.frame = CGRectMake(
self.view.frame.size.width - iv.frame.size.width - margin,
self.view.frame.size.height - iv.frame.size.height - margin,
iv.frame.size.width,
iv.frame.size.height );
iv.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[self.view addSubview:iv];
When the app is starting in portrait, the activity-indicator is positioned correctly. As soon as I rotate the device (or start the app in landscape) the positioning of the activityindicator is wrong.
How can this be fixed?
You also need a flexible top margin, so that the view will slip to up or down as the height of the main view changes. Also, the parent view needs  to autoresizesSubviews set to YES (which is default YES, so you are probably ok).
distanceLabel.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin);
On your view controller, override the method shouldAutorotateToInterfaceOrientation and correct the position when orientation changes.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

Navigation controller affecting app overall background image

I have an application where when it begins, it loads a viewController which loads the Default.png launch image and holds it there for 1.5 seconds, then that image fades out, then fades into another image which will be the background image for my entire application. From here it loads the first viewController and then the buttons and navigation bar fade in.
So it goes SplashScreeVC - Default.png presented
Default.png Fades out
New Image fades in (This is the apps overall background image)
Loads MainVC with buttons and nav bar alpha set to 0.1.
Method called to fade in the nav bar and the buttons in the mainVC
So in my app Delegate I have this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
SplashVC *splash = [[SplashVC alloc] initWithNibName:#"SplashView" bundle:nil];
self.window.rootViewController = splash;
[self.window makeKeyAndVisible];
return YES;
}
So the app loads with the Default.png, which then loads the splashVC which has the Default.png as its background image, this is shown for 1.5 seconds. I then have a some methods to fade out this image, and then fade in the image that will be used as the background image for the entire application. Then it calls the appDelegates MainNav method which loads the Navigation controller. The app Delegates MainNav method is below
-(void) MainNav
{
UIViewController *main = [[MainVC alloc] initWithNibName:#"MainView" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:main];
UIImage *navImage = [UIImage imageNamed:#"NavBarGrey.png"];
//Add the custom image
[[self.navController navigationBar] setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault];
//[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xee2e24)];
[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xe7e7e7)];
self.navController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"backgroundImage.png"]];
self.window.rootViewController = self.navController;
}
The problem is when it moves from the SplashScreen VC to the MainVC, the image suddenly jerks up despite the fact it is the same image that fades in in the SplashVC.
Does anyone have any idea why this is? I am guessing it has something to do with the navigation controller affecting the image size, but not sure what to do to fix it? Do I need to create a new image for the navigation bar background with different dimensions? Or is there another way I can fix this issue?
Any advice would be much appreciated. Thanks!!
Edit: Fixed image jerking to the right, had image width at wrong height, but the image is still jumping up a set amount
Managed to figure it out. Seems to have to make a copy of the image and increase its height by 20 pixels and set that as the navigation bars background image. This offsets the navigation bar problem.
you can set bacround image code like
yourView.setBacroundColur=[UIColour colourWithImagePttern:[UIImage ImageNamed:#""]];

iPad: Popover windows got resized iOS

CGRect rect = CGRectMake(0, 0, 1050, 900);
[wineAdminPopup presentPopoverFromRect:rect inView:master.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Hi I put the above code to make a popup in a tableview. However it doesn't popup in the whole screen. If I want to center it in the iPad screen with no arrow or arrow in the center. How can i do it. Thanks in advance.
The rect parameter in presentPopoverFromRect:... specifies the rectangle at which to anchor the popover, not the size of the presented popover. That would be specified by setting contentSizeForViewInPopover on the popover's content view controller.
If you don't want the arrows and don't need the specific behavior of popovers, then you could
present your view controller modally:
controller.modalPresentationStyle = UIModalPresentationFullScreen; // or UIModalPresentationFormSheet
[self.navigationController presentModalViewController:controller animated:YES];
presentModalViewController is deprecated in iOS 6 and above. Use presentViewController:yourViewController animated:YES completion:nil (parameters animated and completion can be set depending on your requirements). Also if you want to resize yourViewController you need to change self.view.frame and next time your view controller will be of that size.

UIProgressView+Activity Indicator View on a UITableView during data upload

I have a uitableview.
I saw this "effect" and I would replay it:
When the user taps on a button to upload some data on a server, I would a gray (transparent) view with a progress bar (maybe with also an activity indicator) appears on the table.
The table is disabled and can be viewed through the gray view (that is the gray transparent view covers all the table).
How can I achieve this?
Have I create a view with a progressive view on it and then put it in the same xib of the table, disabling it properly programmatically? Or?
Lay a large black UIView over top of the UITableView with an alpha value of 0.5. Then put a spinner (UIActivityIndicatorView) on top of that.
Something like this:
UIView *view = [[UIView alloc] init];
view.frame = myTableView.frame;
// save this view somewhere
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = view.frame;
ac.center = CGPointMake(frame.size.width/2, frame.size.height/2);
[view addSubview:ac];
[ac startAnimating];
[ac release];
[myTableView addSubview:view];
[view release];
Then remove it later with [view removeFromSuperview]