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;
Related
If I want to list some items from a database, do I need to add a UIView and a UITableView to my ViewController? or just add the UITableView to my ViewController?
You must already be having a UIView as part of your ViewController, Just add UITableView as a subview to your UIView.
The UIView of a ViewController can be accessed as [self.view];. So what you need to do is [self.view addSubview:yourTableView];. Using setFrame properly sets it in the x,y,width,height that you need.
Just add the UITableView cause you are already have a UIView, Please check this tutorial on how to use UITableView.
its just depend on your project layout if you want to add tableview then you can use predefined function like didselectrow,moverow,editingrow,willdisplay etc...it totally depend on your need and layout specification and last thing tableview is better than using view instead on another view.
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.
Is there a way to change the "layer" that UIImageView objects are drawn in? Whenever I add an image view to a view controller it defaults to drawing the most recently added one on top of all the others. So if I decide to add a "background" image it is now a "foreground" image and blocks everything else.
There isn't anything in the IB options or in the UIImageView class reference and I haven't been able to find anything here on SO. It's been a problem for a while and it's weird that I haven't seen anything about it before... I think it might just be my semantics coming from a delphi background.
Anyway, does anyone know about this issue / ICANHAZTEHCODEZ to fix it? Or is this just like the UIScrollView problem and poorly supported by the development environment.
This happens when I try to use the editor to arrange the subviews.
You can bring a SubView to Front or Send it background programmatically using
[self.view bringSubviewToFront:yourImageView];
and
[self.view sendSubviewToBack:yourImageView];
when self.view must be the superview of your imageView
In IB, select a UIControl and from top menu bar select Editor->arrage->send to front or back
When you use UIView's addSubview: method, it will add it to the top of the view stack resulting in what you are seeing.
There are numerous other UIView methods you can use to determine the order of subviews. E.g.:
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
- (void)sendSubviewToBack:(UIView *)view;
- (void)bringSubviewToFront:(UIView *)view;
I have two IBActions. In one action I am loading the UIWebview to display a PDF File from my bundle. On clicking the other button the whole UIWebView should get removed from superview.
I have tried using:
[webview removeFromSuperview];
and
webview.hidden=YES;
Neither of these are working. They are hiding my UIWebView for a second, but then it appears again.
Is is
I have created UIWEBVIEW programatically and added the UIWebvieWDelegate in the interface file. But when initializing the UIWebView I didnt set webview.delegate=self; Is it the problem?
have you connected Referencing Outlet to the class's #property in the Interface Builder?
If you don't do it, it would be the a possible reason why you cannot reach the UIWebView in your source code. for your sake, you should check the pointer of webview, if it is nil chronically, there is 100% you have not connected them each other.
I was trying to make a thing like this. The solution that worked for me was to add UIview object as subview to view with the frame of webview and bringing it to top.... When u want to make uiwebview visible, just remove that uiview object from superview.
OK, it seems old question, but also i can see there are almost thousand people have view it, and may have the same problem. so my answer for anyone my have the same issue in the future.
I just been doing something smiler and want to hide the web view when at a certain action.
I have tried the following
-(void)viewDidLoad
{
[super viewDidLoad];
process = [ProcessingData new];
[DetailView setHidden:YES];
DetailView.hidden = YES;
[DetailView removeFromSuperview];
self.DetailView = nil;
}
however it is still not working, as i have few labels in the WebView which are don't disappear when the view load, when I looked at the "StoryBoard" i notes that the labels are not subview of the
can u see the hierarchy of the libels under the WebView, they are subview of the main view, where they suppose to be same as the table view hierarchy
so in may case the WebView is hiding but the labels are not as they are not a part of the Webview.
how to sort this problem, if you really don't need web view use the normal one, otherwise you have to hide all the labels in that view. hope thats helpe
I don't know obj-c but still posting a solution that worked for me in swift. basically you have to use the main thread to remove the webview.
DispatchQueue.main.async {
print("\nremoving webview\n")
self.myWebView.stringByEvaluatingJavaScript(from: "document.body.innerHTML='';")
self.myWebView.removeFromSuperview()
}
Imagine, there is a UIViewController with a UIScrollView in it. At the top of the view there is an UIImageView, some UILabels and other things. Furthermore, there is a UITableView which content is Dynamic Prototypes. I attach a picture to make it clear:
I haven't got a static amount of cells in the UITableView so it could be scrollable. My problem is the following: the UITableView scrolls in itself but I want to scroll the whole View. What is the best possibility to do that?
Possible solutions I've founded today
1) The first thing is: I create a UITableViewController and declare a header section in which I include all my labels, images etc. programmatically (I would love to use the interface builder for that...)
2) Another solution is to calculate the height of the view. I tried the best to do it like this way - but: without success. If this is the best way to do that: Can anybody give an example?
I would ditch the UIScrollView and just use a UITableView. You can add a UIView object as the tableHeaderView of the UITableView just by dragging it in in Interface Builder. Now since everything is part of the UITableView hierarchy, everything will scroll together as expected.
You could also try setting delaysContentTouches to NO on your scrollView. Depending on your setup, this may make the scroll view respond to the touch first instead of the table view.
From Apples UIScrollView Docs:
delaysContentTouches
A Boolean value that determines whether the scroll view delays the
handling of touch-down gestures.
#property(nonatomic) BOOL delaysContentTouches
Discussion
If the value of this property is YES, the scroll view delays handling
the touch-down gesture until it can determine if scrolling is the
intent. If the value is NO , the scroll view immediately calls
touchesShouldBegin:withEvent:inContentView:. The default
value is YES.
You'll have to (as you've mentioned) add the UIView containing the image and buttons to the actual UITableView. Embedding it in the scroll view will produce the undesired behavior that you're seeing.
I would recommend returning the UIView as the header view for the first section of your table view. You can do this by implementing the UITableViewDelegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
If you maintain an IBOutlet to the view containing your image/labels, you can return it here.
this is same demo i hope its helps you from iphone sorce code library
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html
thank you