Presenting UIView similar to UIAlertView in SplitviewController - objective-c

I am using SplitViewController. Now i want to present a UIView similar to UIAlertView when i select a row in detail view controller.
I have tried presenting the view like this,
[self presentModalViewController:view animated:YES];
but my view is getting loaded from the bottom. So can anyone give me some suggestion or sample to achieve this.
Also i want to increase my master view width. I tried to change the size in pop over but it doesn't work.
Thanks in advance.

Add your view as a subview to the (split-)viewcontrollers view
[splitViewController.view addSubview: yourView];
You can set your views background color to clearColor and create another view on it to make it look like a smaller view in the middle of the screen.

Related

Push a UITableView modally as a 'transparent layer above' my current View

I need your help.
I want to push a UITableView modally as a 'transparent layer above' my current View.
The TableView exists already and I want to reuse it in a slightly different context.
So the User creates a new Object inside the View, he gives it a name and a description and a topic, when he does so I want to show all existing topics(the TableView) and pick one, then the TableView should disappear.
All its functionality is exactly like usual and it isn't allowed to cover the NavigationBar.
So my Question: is that possible and how?
I hope I could make myself understood.
If you want to present a tableviewcontroller which will be transparent over your view controller, it is possible .
Create your tableviewcontroller instance and before presenting the viewcontroller add the following code.
tableVC.providesPresentationContextTransitionStyle = YES;
tableVC.definesPresentationContext = YES;
[tableVC setModalPresentationStyle:UIModalPresentationOverCurrentContext];
In your tableVC set backgroundcolor to clearcolor It might work

UIView, UITableView frame misalignment iOS 8

I am using UITableViewController,UICollectionViewController in my app. On ViewDidLoad the view looks great like the following.
But after if I undergo its respective detail view and back to UITableView or UICollectionView it align like the following
I even tried setting self.tableView.frame = CGRectMake(0,0,width,height); on viewDidAppear but no luck.
Here is my tableView properties: (I also tried both check/uncheck these properties). Anyone here kindly suggest the possible solution or reason for this problem..
NOTE: Autolayout for storyboard is NOT used..
Put this code in your UITableViewController ViewDidLoad
self.navigationController.navigationBar.translucent = NO;

Always visible UIView

I want to place a UIView that will inform the user what is the status of the app. I want that view to be visible even if the user switches views, same thing as the UINavigationBar is always visible, but I don't want to use that bar, I would like to add another view that will show a message.
How can this be done? I can't add the view to the current view, because it will disappear, if the user changes views.
It should be added to the window? But how? I would then have to resize the views so that my new view can fit, but how?
Thanks.
Create a container view controller and set it as the rootViewController of the apps window.
Inside this container you have your status view, and you also resize the windows real rootViewController to take up the remaining space as a subview. If you are using a standard container view conrtoller (tab, navigation etc) as the root then you can use standard navigation methods and the status view will always be visible
There would be problems if you wanted to present modal views though, since these would go over the top of the status view
In your appDelegate.m add your view as subView of window.
UIView *mainBg = [[UIView alloc] init];
mainBg.frame = newframe;
[self.window addSubview:mainBg];
If you have a UINavigationController you can add your view to its view.
[self.navigationController.view addSubView:yourView];
Presenting modal views would cover the view, as stated in the other answer.

How to make current view a scrollview? iOS / Objective C

I have a view (that is actually part of a UINavigationControllers view) that i want to make a scrollview.
how do i do that?
could i do something like this:
UIScrollView * content = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.view = content
(obviously that doesn't work, but is there a way to do it like that)?
Yes, it is, you have to implement delegates, and set the contentSize. The best tutorial on scrollViews ever I found is:
http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content
You are on a good way!
You can create the scroll view programmatically like you do and then add the existing view as a subview of this new scroll view, examine addSubview: (which works on all UIViews and subclasses like UIScrollView as well). I won't say this is the solution or even a clean one for that matter, but if you read about addSubview: you can at least figure out how to have a view live inside a scroll view...

Need help with refreshing UIView in iPhone SDK

I have a simple drill down navigation app. On the detail view, I am drawing a few 20x20 sized UIImages, depending upon the row selected in the navigation items. These images are drawn as subviews over the detail view when a row is selected.Now when I get to the "detail view" I have set up a couple of buttons, which when pressed, will rearrange the small images. For this I need to clear the previous images and redraw them at different places in the view. I have a method like:
[MyView changeImagePositionwithPosnumber:"number selected by buttons"]
I cannot pass this method when the button is pressed since it draws over the existing images.
How do I refresh the view to pass this method ? Do I need to implement draw rect for this?
I do not quite understand drawrect and am not sure how to implement it.
In short whatever the navigation controller does when you go away from detail view, I want to do, so I can refresh my view and draw new images on it.
Any help on this is greatly appreciated. I am still a newbie.
This worked for me:
UIView *view:
for(UIView *subview in [view subviews]) {
[subview removeFromSuperview];
}
Thanks