iPhone UITableView PlainStyle with custom background image - done “entirely” in code

后端 未结 5 961
情深已故
情深已故 2021-02-09 08:28

I have been all over the place, seems the UITableView with a static background issue is well documented, but no one with a straight forward solution? Im building my

5条回答
  •  臣服心动
    2021-02-09 08:47

    Thanks Coneybeare.

    It doesn't crash anymore and the background image turns up just perfect (along with my navigationController in the top) However, still no visible tableView? just the background image and the navigationControllerBar:

    This is my implementation:

    - (void)loadView {
    [super loadView];
    
    UIImageView *imageView = [[[UIImageView alloc] initWithFrame:self.view.bounds] autorelease];
    [imageView setImage:[UIImage imageNamed:@"carbon_background.png"]];
    [self.view addSubview:imageView];
    
    [self.tableView = [[UIView alloc] initWithFrame:self.view.bounds] autorelease];
    
    [self.tableView setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:self.tableView];
    

    }

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView {
    return 1;
    

    }

    - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section {
    return 3;
    

    }

    - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = @"Hello, World";
    
    return cell;
    

    }

    //commit edit, didSelectRow, memory … etc.

    The forum wasn't up for an entire .m file in one go. Please tell me if I left something out that could help indicate an error.

    I thought maybe it was the order of the layers and tried this without any luck:

        [self.view sendSubviewToBack:imageView];
    

    Hope I missed something obvious.

    Thanks for your time:)

提交回复
热议问题