UITableViewCell 's xib:
do not pass up the figure , the general situation is 3 label and two imageview
implementation class ( an example of the Internet ) :
#import "MessageTableCell.h"
@implementation MessageTableCell
@synthesize imageView;
@synthesize nameLabel;
@synthesize decLabel;
@synthesize locLabel;
@synthesize helpImgeView;
@synthesize image;
@synthesize helpImage;
@synthesize name;
@synthesize dec;
@synthesize loc;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setImage:(UIImage *)img {
if (![img isEqual:image]) {
image = [img copy];
self.imageView.image = image;
}
}
-(void)setName:(NSString *)n {
if (![n isEqualToString:name]) {
name = [n copy];
self.nameLabel.text = name;
}
}
-(void)setDec:(NSString *)d {
if (![d isEqualToString:dec]) {
dec = [d copy];
self.decLabel.text = dec;
}
}
-(void)setLoc:(NSString *)l {
if (![l isEqualToString:loc]) {
loc = [l copy];
self.locLabel.text = loc;
}
}
- (void)setHelpImage:(UIImage *)img {
if (![img isEqual:helpImage]) {
helpImage = [img copy];
self.helpImgeView.image = helpImage;
}
}
@end
in the table view with this MessageTableCell , the data are normal , that is not child appropriate click event , seeking help !
------ Solution ---------------------------------------- ----
UserInterfaceEnabled = YES;?
------ Solution ---------------------------- ----------------
didSelectRowAtIndexPath this method is the response object tableview delegate methods to confirm tableview.delegate = self; sentence has been added < br> ------ Solution ----------------------------------------- ---
the h file sent to look
------ Solution -------------------------- ------------------
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath look at this implementation of the method . .
------ Solution ---------------------------------------- ----
XIB file settings should be the issue .
You can try code associated manner .
Example : http://code4app.com/ios/% E7% AE% 80% E5% 8D% 95UITableViewDemo/505548916803fa6b06000000
------ Solution ---------- ----------------------------------
to manually set the period of insurance is best proxy references
self.tableView.delegate = self;
self.tableView.datasource = self;
If you have a good set , is generally able to visit didSelectedRowAtIndex: protocol method . Or check this possibility to be larger.
There is in the UITableViewCell - (void) setSelected: (BOOL) selected animated: (BOOL) animated method can also respond to click events.
------ eference --------------------------------------- < br>
added , useless yo. . .
------ eference --------------------------------------- < br>
tableview.delegate and tableview.dataSource have been associated with the IB , or I send the code to the younger prawns look ? Code is not complex , it is a short test code
------ eference - --------------------------------------
cell . h files
#import <UIKit/UIKit.h>
@interface MessageTableCell : UITableViewCell{
IBOutlet UIImageView * imageView;
IBOutlet UILabel * nameLabel;
IBOutlet UILabel * decLabel;
IBOutlet UILabel * locLabel;
IBOutlet UIImageView *helpImgeView;
}
@property (nonatomic, retain) IBOutlet UIImageView * imageView;
@property (nonatomic, retain) IBOutlet UILabel * nameLabel;
@property (nonatomic, retain) IBOutlet UILabel * decLabel;
@property (nonatomic, retain) IBOutlet UILabel * locLabel;
@property (nonatomic, retain) IBOutlet UIImageView *helpImgeView;
@property (copy, nonatomic) UIImage *image;
@property (copy, nonatomic) UIImage *helpImage;
@property (copy, nonatomic) NSString *name;
@property (copy, nonatomic) NSString *dec;
@property (copy, nonatomic) NSString *loc;
@end
controller . h files :
#import <UIKit/UIKit.h>
@interface LatestViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
@end
------ eference ------------------------------------ ---
or prawn with custom cell can respond to a simple example , you can let the younger look, I find their own reasons for contrast .
------ eference - --------------------------------------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyCellIdentifier = @"MyCellIdentifier";
static BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"MessageTableCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:MyCellIdentifier];
nibsRegistered = YES;
}
MessageTableCell *cell = [tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];
if (cell == nil) {
cell = [[MessageTableCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyCellIdentifier];
}
NSUInteger row = [indexPath row];
cell.name = [dataList objectAtIndex:row];//datalist是一些假数据
cell.dec = [dataList objectAtIndex:row];
cell.loc = [dataList objectAtIndex:row];
cell.image = [imageList objectAtIndex:row];
cell.helpImage = [UIImage imageNamed:@"chat_message.png"];
[cell setUserInteractionEnabled:YES];
return cell;
}
------ eference ------------------------------------- -
Thank you friends , I found the root cause ,
- (NSIndexPath *)tableView:(UITableView *)tableView
willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
return nil;
}
Because this method , just learning these methods are not familiar with , just delete this approach can be, and then check the next development manual to this approach, there is such a sentence:
Return Value
An index-path object that confirms or alters the selected row. Return an NSIndexPath object other than indexPath if you want another cell to be selected. Return nil if you don '???? t want the row selected.
is nil reason , a good pit father ah , the novice can not afford to really hurt . . .
------ eference - --------------------------------------
landlord tableview which added the methods later I still can not jump by clicking the cell , is why
------ eference ------------------------- --------------
I see tutorials and custom cell like you -
没有评论:
发表评论