How can i customize the Vertical postion of UITableView of UITableViewController.I am trying to show the table(3 cells) at the middle of the window . My class is inheriting UITableViewController class. Please someone give me suggestions. or Alternative ways to do this.
Thank You.
Try to create an UIViewController, and put an UITableView in it. I think you can set the origin.y of the tableView. Make sure to set the UITableView's datasource and delegate. Good luck.
Related
I would like to know if I could add a UIPageControl to a TableViewController in order to flip sideways between different tables?
What is the right way to go about this?
Is there some sample code to implement this? The code on the Apple website looks complicated for a beginner like me, does not use Storyboards and it only deals with some images.
Thanks for your help!
Instead of using TableViewController, I would just use ViewController implementing UITableView data source and delegate.
Place UITableView and UIPageControl in that and then on change in UIPageControl, change the data source of the tableview and use UITableView.reloadSections with appropriate UITableViewRowAnimation (Right or Left).
You can also add gesture recognizers on the tableview to allow swipe left/right.
I have a TableView with one cell and I want to insert in this cell a lot of text so I think I'll need to use a ScrollView for scroll the text.
How can I insert? Is correct this method?
This is a help in the application, is correct use this modality?
Sorry but I'm a beginner and I don't have an iPhone or iPod, thanks!
While I concur with 7KV7's original comment, it doesn't look like there is need of a tableview in this scenario...
Just in case someone else happens upon this looking for an answer to the "Scrollview in a Tableview" question here are few clarifying points for the above comments.
The technical problem with having a tableview and a scrollview together on the same view is that UITableView is already a descendent of UIScrollView and if you attempt to handle both in the same view then you will end up with quite a mess with conflicting delegate messages.
As suggested by iPhonePgr, you can create a custom UITableViewCell. The first thought would be to let the UITableViewCell act as the delegate for it's own scroll view. The problem here is that the cell and it's contents could be discarded or reused at any moment as part of tableview's dequeue functionality.
So some ground rules to guide your implementation:
Whatever your solution, you're probably going to end up making a custom controller class, possibly derived from NSObject and implementing UIScrollViewDelegate.
The custom controller object acts as the mediator between the model object and the cell.
You will probably have an array or array-of-arrays that mirrors the model hierarchy driving the UITableView structure.
Because the cells can be discarded at any time you will have restore the scroll view state on cell initialization and preserve the state has part of handling your delegate actions or through a custom UITableViewCell implementing prepareForReuse.
Hopefully these points will come in useful to anyone who runs across this entry.
You need to create a custom cell by inheriting UITableViewCell and then add UIScrollView in the customcell. Then Use that cell in the Table view.
you can put your text in UITextView and add it as a subview in your UITableViewCell,because
UITextView is inherited from UIScrollView,
No need to add UIScrollView if you use UITextView
When you create UITableView you implement a number of delegate method which you can see by pressing the window key and then double clicking the UITableView delegate . In one of the methods you can set the cell height as per your requirement. By doing this your cell height can vary.
- (CGFloat)tableView:(UITableView *)resultTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 150;
}
As your table has a defined height, when the text in cell will be too much to contain into a scrollview will be automatically inserted.
do anyone have experience with UITableView inside a custom UITableViewCell ?
I had a try and the UITableView in the UITableViewCell looks like that can't respond to user inputs (i.e scrolling).
Before going any further I would like to know if I am wasting my time !
Does anyone have seen something like that around ? Any reference would be helpful.
Thanks
I haven't done this, but I discourage this. This could cause odd things to happen.
In a similar vein, Apple says not to use UIWebView inside of a UIScrollView. The reason is because a web view is a subclass of the scroll view. Nesting them can cause unexpected behaviors. Note that the table view is also a subclass of the scroll view. While Apple doesn't explicitly mention your case, I assume that it is the same idea.
If yo must, subclass UITableViewCell and see what happens. It's not that difficult. Make the cell implement the UITableViewDelegate protocol.
Since the parent TableView responds to the vertical swipe gesture, your child TableView is not going to ever see it. Where should the swipe gesture "go"? It has to go one place or the other, so one of the TableViews will always not behave "correctly". I do think that trying to put a TableView inside a TableViewCell and getting it to work just like a root TableView is probably a waste of time.
i added some views (every view has its own viewcontroller and nib) to an UIScrollView. How can I access the ScrollView from within the UIViews I've added?
self.view.superview doesn't get me the UIScrollView properties. I need to disable scrollEnabled from within an UIView.
Thank you!
Maybe try (UIScrollView*)(self.view.superview).property to access the property you want :-)
It should work.
But maybe with an Delegate it would be better :-p
Good Luck !
I have a doubt in accessory view in UITableView. The doubt is
Is it possible to add more than one button in UItableviewcell using accessryView if so plz guide me.
thanks in advance
You could use a custom view that has two buttons as subviews, and add this as the accessoryView, but you are probably better off with a custom UITableViewCell.