Rectangle 27 0

You need to add contentOffset, I would like to refer you to this page which explains the use of it.

Here's the solution anyway, this is assuming that the variable name of your tableview is tableView and is set as a property of the class:

CGRect loadingScreenFrame = CGRectMake([[UIScreen mainScreen] bounds].origin.x + self.tableView.contentOffset.x,
                                       [[UIScreen mainScreen] bounds].origin.y + self.tableView.contentOffset.y,
                                       [[UIScreen mainScreen] bounds].size.width,
                                       [[UIScreen mainScreen] bounds].size.height);

UIView *blackScreen = [[UIView alloc] initWithFrame:loadingScreenFrame];
blackScreen.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
blackScreen.tag = LOADING_SCREEN_TAG;

UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

spinner.center = CGPointMake((CGRectGetWidth(self.view.bounds)/2) + self.tableView.contentOffset.x,
                             (CGRectGetHeight(self.view.bounds)/2.3) + self.tableView.contentOffset.y);

spinner.tag = SPINNER_TAG;

[spinner startAnimating];

[self.view addSubview:blackScreen];
[self.view addSubview:spinner];

[self.view setUserInteractionEnabled:NO];

objective c - UIView does not show properly when the uitableview is sc...

objective-c uitableview uiview
Rectangle 27 0

Yes, it is possible. You could just go ahead and change the size of the UITableView dynamically as part of the animation that slides up the view. If you want to do what the UITableView actually does in response to the keyboard, leave its size alone and instead change its content inset and scroll indicator insets. See my answer here and the examples linked to:

objective c - Resize UITableView when I slide up a UIView, just like h...

objective-c ios cocoa-touch uitableview
Rectangle 27 0

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.

objective c - Xcode - When to use a UIView or a UITableView? - Stack O...

objective-c ios uitableview uiview uiviewcontroller
Rectangle 27 0

I'm almost sure that this error occurs because you have improperly connected your UITableView . You should delete an ivar mTableView, an IB outlet property tableView and @synthesize . Then DELETE AN OUTLET IN IB. Then, connect it again by dragging it from the interface builder and DO NOT TYPE ANY CODE in your class. Xcode will do all stuff for you (create a property, synthesize it and do MM things)

I did it your way, still nothing, the cellForRowAtIndexPath seems to run 5 times (I put NSLog inside) but theres still no tablecells. (I'm at work, I cannot upload images)

nevertheless I'm still sure that the problem is in wrong connection of outlets...try to delete ALL outlets and connect them again. I've had this problem a few days ago...My problem was in missing outlet

btw, the property MUST NOT BE READ-ONLY it should looks like: '@property (retain, nonatomic) IBOutlet UITableView *wallTableView;' with an ivar 'UITableView *wallTableView;' and synthersize '@synthesize wallTableView;' note you don't type this code.

objective c - UITableView not populating from UIView - Stack Overflow

objective-c uiview uitableview delegates
Rectangle 27 0

Make sure that you have set the delegate and the datasource of the table within Interface Builder

objective c - UITableView not populating from UIView - Stack Overflow

objective-c uiview uitableview delegates
Rectangle 27 0

As UITableViewDelegate is a protocol, you can cast as

tableView.delegate = (id < UITableViewDelegate >)self.nextResponder. This tells the compiler that self.nextResponder is any object that confirms to UITableViewDelegate protocol.

If you know that the nextResponder is of any perticular class lets say UIViewController, you can write as

tableView.delegate = (UIViewController < UITableViewDelegate>*)self.nextResponder. This tells compiler that nextResponder is of type UIViewController class that confirms to UITableViewDelegate protocol.

objective c - Cast UIView nextResponder to UITableView delegate - Stac...

objective-c uiview uiviewcontroller casting delegates
Rectangle 27 0

Views should know how to paint themselves and layout their sub views, depending on their properties, and that's it.

You definitely should let a controller class be the delegate instead of the view itself.

The delegate controller doesn't have to be the view controller that displays the view, though. It could easily be a completely separate controller class that only knows how to handle what the view requires.

Thanks for your answer. I'd thought about that. So you're saying I should create a new class FamilyMembersTableViewController (that is not a viewController subclass) and instantiate that each time I need to display a new tableView? And this would act as a go-between for the Family model and FamilyView? This would keep MVC clean, but seems a little unnecessary, as the FamilyViews are awfully specialized anyway, and would be tightly coupled with their tableControllers.

I think a separate controller is the best solution. In ver. 2.0 of your app, you'll be implementing all this amazingly cool stuff, that would only make sense in a controller, and then you'll have to refactor. If you follow the MVC way of doing it now, you'll thank yourself later. :)

The more I think about this, the clearer it becomes that this is the way to go. I've implemented this, and it has no ill side effects. Thank you for helping me see the solution that should have been obvious :) (Though now I face an even harder problem: What should I name this class? To stay in the example, FamilyMemberTableViewController seems both obvious and confusing, since it is neither a UIViewController nor UITableViewController subclass, but it is a controller for a UITableView.)

UITableViewController
UITableView
FamilyMemberTableController

Yeah, that'll probably be the final name. Purely out of interest, though, is it the controller for the table, or is it the controller for a UITableView? Where does one start and the other end? Does UIKit even make the distinction?

objective c - Custom UIView as UITableView delegate and datasource? - ...

objective-c cocoa-touch ipad uitableview uiview
Rectangle 27 0

I have found it. The image was not right. The image was downloaded from the web as .gif . I opened it in photoshop and saved it as .png but it did not saved correctly. I created a new image in photoshop and copy the one i had in that new image. I saved it as .png and it worked.

objective c - UItableview headerview with custom uiview? - Stack Overf...

objective-c ios uitableview uiview
Rectangle 27 0

UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, self.tableView.bounds.size.height)];
[backgroundView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]]]; 
[self.tableView setBackgroundView:backgroundView];

and in the UIView I just used:

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];

objective c - Inconsistency between UIView and UITableView in backgrou...

objective-c xcode uitableview uiview background-image
Rectangle 27 0

A solution would be to not add the spinning view to the tableview but rather to its superview. It seems like you are probably using a UITableViewController which would mean that you would need to restructure your code to use a UIViewController to make this work. Adding both the UITableView and the spinner view to the view of the UIViewController would also achieve what you are looking for without having to set the center based on the content offset.

objective c - UIView does not show properly when the uitableview is sc...

objective-c uitableview uiview
Rectangle 27 0

You must already be having a UIView as part of your ViewController, Just add UITableView as a subview to your UIView.

UIView
ViewController
[self.view];
[self.view addSubview:yourTableView];
setFrame

Ok I understand. Should I also create my own UIView subclass and hook that into the UIView? If so, what is the advantage?

yes you could do that. Dont think of it as an advantage, it more of convenience. If you need a container where you want to have say 1 UIImageView, 1 UILabel. You could create a UIView and put these elements in that view. so really it depends on your needs.

I was watching the Standford video series on ItunesU and Hegarty says to always create a subclass.

objective c - Xcode - When to use a UIView or a UITableView? - Stack O...

objective-c ios uitableview uiview uiviewcontroller
Rectangle 27 0

Just add the UITableView cause you are already have a UIView, Please check this tutorial on how to use UITableView.

objective c - Xcode - When to use a UIView or a UITableView? - Stack O...

objective-c ios uitableview uiview uiviewcontroller
Rectangle 27 0

PhotoDetailsHeaderView
@property (nonatomic, strong) PhotoDetailsHeaderView *headerView;

Then calculate its expected frame in viewDidLayoutSubviews. If it needs updating, update its frame and re-set the tableHeaderView property. This last step will force the tableView to adapt to the header's updated frame.

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];

    CGRect expectedFrame = CGRectMake(0.0,0.0,self.tableview.size.width,self.tableView.size.width + 50.0);

    if (!CGRectEqualToRect(self.headerView.frame, expectedFrame)) {
        self.headerView.frame = expectedFrame;
        self.tableView.tableHeaderView = self.headerView;
    }
}

With this solution I get the desired result. Thank you. I was hoping to avoid writing code, I wanted to avoid writing in sizes in code but if cannot do it in other ways, that's okay. The result would be great to do everything with autolayout. very much cleaner ..

To achieve the same thing with auto layout you will need to calculate the frame using systemLayoutSizeFittingSize:. See stackoverflow.com/a/28102175

I tried but unfortunately the height is zero. It does not work in my case

That probably means your constraints allow for a zero height; perhaps nothing is pinned to the bottom of the superview. Will you be marking this answer as correct?

objective c - UIVIew from XIB with Autolayout to UItableView Header - ...

objective-c uitableview xcode6 autolayout xib
Rectangle 27 0

try this Regiseter a cell class with tabel

- (void)viewDidLoad
{
    [super viewDidLoad];

    displayCustomUnitTableView = [[UITableView alloc]initWithFrame:CGRectMake(52.0, 110.0, 180.0, 110.0) style:UITableViewStylePlain];
displayCustomUnitTableView.delegate = self;
displayCustomUnitTableView.dataSource = self;
displayCustomUnitTableView.tag = 2;
displayCustomUnitTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
displayCustomUnitTableView.separatorColor = [UIColor blackColor];
displayCustomUnitTableView.rowHeight = 30.f;
[displayCustomUnitTableView setBackgroundColor:[ContentViewController colorFromHexString:@"#BCC9D1"]];
[displayCustomUnitTableView setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
[displayCustomUnitTableView setAllowsSelection:YES];
[displayView addSubview:displayCustomUnitTableView];

    [displayCustomUnitTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"identifier"];

}

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 1;}



    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"i" forIndexPath:indexPath];

        /*

         Write code

         */
         cell.textLabel.text= @"hello";


        return cell;

    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        NSLog(@"Click");
    }

still its not getting called

are you sure you register cell class with tabel

objective c - after adding uitableview to uiview didselectrowatindexpa...

ios objective-c uitableview didselectrowatindexpath
Rectangle 27 0

The view with 3 buttons needs to be taken as the header view of table. Take the outlet of that view.

[tableView setHeaderView:yourView];

You need to set this in the viewDidLoad of your view controller.

objective c - Move UIView above UITableView when user Scrolls Down - S...

objective-c iphone xcode uitableview swift
Rectangle 27 0

You can simply copy and paste your UITableView from the UITableViewController to a new UIViewController:

Then you need to create a new custom UIViewController class file (to replace your UITableViewController) and copy and paste the programmatic control functions. You will also need to assign the proper delegates to the new UIViewController <UITableViewDataSource, UITableViewDelegate>. In the viewDidLoad function you must assign the new controller as the the UITableView's delegate and datasource. If that is not clear you can find many tutorials online to explain the details.

Awesome, did this and it worked relatively well and bug free. Thanks!

objective c - Change UITableView to UIView in Storyboards - Stack Over...

objective-c xcode storyboard apple
Rectangle 27 0

Ok, it was easier than I thought. In my case, when I touch a row, I want the picker to show and the tableView to change its height, so I use:

[UIView animateWithDuration:0.4 delay:0.0 options: UIViewAnimationCurveEaseOut animations:^{

    self.pickerView.frame = CGRectMake(0, self.view.bounds.size.height-200, self.view.bounds.size.width, self.pickerView.frame.size.height);

    // shrink the table vertical size to make room for the date picker
    CGRect newFrame = self.tableView.frame;
    newFrame.size.height -= self.pickerView.frame.size.height;
    self.tableView.frame = newFrame;

} completion:nil];

Then when I click the done button, and want to return the tableView back to the full height and hide my datePicker, I use:

- (void)doneWithPicker:(BOOL)remove {

    CGRect newFrame = self.tableView.frame;
    newFrame.size.height += self.pickerView.frame.size.height;
    self.tableView.frame = newFrame;

    [UIView animateWithDuration:0.4 delay:0.0 options: UIViewAnimationCurveEaseOut animations:^{
        self.pickerView.frame = CGRectMake(0, self.view.bounds.size.height+300, self.view.bounds.size.width, self.pickerView.frame.size.height);
    } completion:^(BOOL finished){
        if (remove) {
            [self.pickerView removeFromSuperview];
            self.pickerView = nil;
        }
    }];

}

Also, when adding the pickerView as a subview, make sure to add it to the window:

[self.view.window addSubview:self.pickerView];

objective c - Resize UITableView when I slide up a UIView, just like h...

objective-c ios cocoa-touch uitableview
Rectangle 27 0

The problem is probably that in iOS you have to reset the header of the table view manually (if it has changed its size). Try something along these lines:

CGRect newFrame = imageView.frame;
imageView.size.height = imageView.size.width;
imageView.frame = newFrame;
[self.tableView setTableHeaderView:imageView];

This code should be in -(void)viewDidLayoutSubviews method of your view controller.

objective c - UIVIew from XIB with Autolayout to UItableView Header - ...

objective-c uitableview xcode6 autolayout xib
Rectangle 27 0

As UITableViewDelegate is a protocol, you can cast as

tableView.delegate = (id < UITableViewDelegate >)self.nextResponder. This tells the compiler that self.nextResponder is any object that confirms to UITableViewDelegate protocol.

If you know that the nextResponder is of any perticular class lets say UIViewController, you can write as

tableView.delegate = (UIViewController < UITableViewDelegate>*)self.nextResponder. This tells compiler that nextResponder is of type UIViewController class that confirms to UITableViewDelegate protocol.

objective c - Cast UIView nextResponder to UITableView delegate - Stac...

objective-c uiview uiviewcontroller casting delegates
Rectangle 27 0

If you do not do anything with your IBOutlet why do you have it? The method

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

is Called by the nib-File for the tableView instance created in the nib.Your Class as a delegate of this instance receives this call. Being the delegate of the tableView in the nib is all you need.

objective c - UITableView not populating from UIView - Stack Overflow

objective-c uiview uitableview delegates