Tag in TextField not working - objective-c

#import <UIKit/UIKit.h>
#interface CustomTF : UITextField
-(void)awakeFromNib;
#end
and
#import "CustomTF.h"
#implementation CustomTF
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
-(void)awakeFromNib
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{ // for iphone ....
self.textColor = [UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1];
// self.font = [UIFont fontWithName:#"HelveticaNeueLT-LightCond" size:15];
self.borderStyle = UITextBorderStyleRoundedRect;
self.font = [UIFont systemFontOfSize:15];
// self.placeholder = #"enter text";
self.autocorrectionType = UITextAutocorrectionTypeNo;
self.keyboardType = UIKeyboardTypeDefault;
self.returnKeyType = UIReturnKeyDefault;
self.clearButtonMode = UITextFieldViewModeWhileEditing;
self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.font = [UIFont fontWithName:#"Helvetica" size:15];
}
else
{ // for ipad .....
self.textColor = [UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1];
// self.font = [UIFont fontWithName:#"Anivers-Regular" size:17];
self.font = [UIFont fontWithName:#"Helvetica" size:17];
}
// self.layer.borderColor = [UIColor blackColor].CGColor;
// self.layer.borderWidth = 1.0f;
}
#end
// creating setTimeTF at run time according to
numberOfTime=5;
for (int i=1; i<= numberOfTime; i++) {
setTimeLabel = [[CustomLBL alloc] initWithFrame:CGRectMake(lblX, lblY, lblW, lblH)];
setTimeTF = [[CustomTF alloc] initWithFrame:CGRectMake(tfX, tfY, tfW, tfH)];
setTimeTF.placeholder = #"HH:MM";
lblY = lblY + lblH + 10;
tfY = tfY + tfH + 10;
setTimeTF.borderStyle = UITextBorderStyleRoundedRect;
setTimeTF.font = [UIFont systemFontOfSize:15];
setTimeTF.autocorrectionType = UITextAutocorrectionTypeNo;
setTimeTF.keyboardType = UIKeyboardTypeDefault;
setTimeTF.returnKeyType = UIReturnKeyDone;
setTimeTF.clearButtonMode = UITextFieldViewModeWhileEditing;
setTimeTF.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
setTimeTF.delegate = self;
setTimeTF.backgroundColor=[UIColor clearColor];
if (i == 1) {
setTimeTF.tag = 11;
setTimeLabel.text = #"Set 1st Time";
}
else if (i == 2){
//setTimeTF.tag = 22;
setTimeLabel.text = #"Set 2nd Time";
}
else if (i == 3){
setTimeTF.tag = 33;
setTimeLabel.text = #"Set 3rd Time";
}
else if (i == 4){
setTimeTF.tag = 44;
setTimeLabel.text = #"Set 4th Time";
}
else if (i == 5){
setTimeTF.tag = 55;
setTimeLabel.text = #"Set 5th Time";
}
[setTimeVw addSubview:setTimeLabel];
[setTimeVw addSubview:setTimeTF];
}
MY Problem:
in delegate method of textFieldShouldBeginEditing , its not going to condition
if (textField == self.setTimeTF) and getting tag set always 55 (last tag)
#pragma mark - TextField Delegates
- (BOOL) textFieldShouldBeginEditing: (UITextField *) textField
{
if (textField == self.setTimeTF)
{
if (setTimeTF.tag == 11)
{
[self showTimePicker:setTimeTF.tag];
return NO;
}
else if (setTimeTF.tag == 22)
{
[self showTimePicker];
return NO;
}
else if (setTimeTF.tag == 33)
{
[self showTimePicker];
return NO;
}
else if (setTimeTF.tag == 44)
{
[self showTimePicker];
return NO;
}
else if (setTimeTF.tag == 55)
{
[self showTimePicker];
return NO;
}
}
return YES;
// return NO;
}

Related

selection of cell is repeating while loading in tableview in objective c

Tick mark button selection of uitableview cell is repeating when scroll the tableview. and the tableview is already loaded with an array of item. but i need to do multi selection of cells in tableview
-(void)checkButtonClicked:(UIButton *)sender{
CGPoint touchPoint = [sender convertPoint:CGPointZero toView:_tableView];
NSIndexPath *indexPath = [_tableView indexPathForRowAtPoint:touchPoint];
sender.tag = indexPath.row;
selectedIndexForPassing = sender.tag;
if([_selectionArray count ] == 0){
_uploadSheetBtn.enabled = NO;
if (sender.selected){
sender.selected = false;
}
else{
TCSTimeSheet * sc = self.timesheetList[selectedIndexForPassing];
_canEdit = sc.canEdit;
if([_canEdit isEqual: #"1"]){
sender.selected = true;
_uploadSheetBtn.enabled = YES;
TCSTimeSheet * sc = self.timesheetList[selectedIndexForPassing];
NSDictionary * detailsDictionary= [NSDictionary dictionaryWithObjectsAndKeys:sc.timesheetDetailId,#"timesheetDetailId",sc.scheduleEmployeeDetailId, #"scheduleDetailId",sc.lastUpdatedTime,#"lastUpdatedTime",sc.timesheetStatus,#"timesheetStatus",sc.shiftDate , #"shiftDate",sc.employeeId ,#"employeeId",nil];
[_storingArray addObject:detailsDictionary];
[_selectionArray addObject:sc.clientId];
}
}
}
here is my cell for at indexpath code
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * reuseIdentifier = #"timeSheetCell" ;
TimeSheetCell * dataCell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
TCSTimeSheet * currentTimeSheet = self.timesheetList[indexPath.row] ;
_statusIndicator = currentTimeSheet.timesheetStatus;
_timesheetDetailId = currentTimeSheet.timesheetDetailId;
_timesheetDocId = currentTimeSheet.timesheetDocId;
_documentType = currentTimeSheet.documentType;
if(![currentTimeSheet.notes isEqual:#""]){
_notes = currentTimeSheet.notes;
}
if (dataCell == nil)
{
dataCell = [[TimeSheetCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
}
dataCell.clientNameLbl.text = currentTimeSheet.clientName;
dataCell.dayLbl.text = currentTimeSheet.shiftDay;
dataCell.dateLbl.text = currentTimeSheet.shiftDate;
dataCell.shiftTime.text = currentTimeSheet.shiftTime;
dataCell.shiftType.text = currentTimeSheet.shiftType;
[dataCell.checkBtn addTarget:self action:#selector(checkButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
if ([_statusIndicator isEqual: #"D"]) {
if([currentTimeSheet.canEdit isEqual:#"1"]) {
[dataCell.remarkBtn setImage:[UIImage imageNamed:#"selectedMessage_btn"] forState:UIControlStateNormal];
dataCell.containerView.backgroundColor = [UIColor colorWithDisplayP3Red:255.0 green:191.0 blue:0 alpha:0.5];
if(![currentTimeSheet.notes isEqual:#""]){
[dataCell.remarkBtn addTarget:self action:#selector(presentMessagePopUp:) forControlEvents:UIControlEventTouchUpInside];
}
}
}
else if ([_statusIndicator isEqual: #"U"]){
if([currentTimeSheet.canDelete isEqual:#"1"]){
[dataCell.remarkBtn setImage:[UIImage imageNamed:#"selectedDelete_btn"] forState:UIControlStateNormal];
[dataCell.remarkBtn addTarget:self action:#selector(deleteDocument:) forControlEvents:UIControlEventTouchUpInside];
}
}
else{
[dataCell.remarkBtn setImage:[UIImage imageNamed:#"unselectedDelete_btn"] forState:UIControlStateNormal];
dataCell.containerView.backgroundColor = [UIColor colorWithDisplayP3Red:255 green:255 blue:255 alpha:1];
[dataCell.checkBtn setImage:[UIImage imageNamed:#"timesheetUnselectedTick"] forState:UIControlStateNormal];
}
if([_timesheetDocId isEqual: #""] && [_timesheetDetailId isEqual:#""]) {
[dataCell.previewBtn setImage:[UIImage imageNamed:#"unselectedView_btn"] forState:UIControlStateNormal];
}
else {
[dataCell.previewBtn setImage:[UIImage imageNamed:#"selectedView_btn"] forState:UIControlStateNormal];
if([_documentType isEqual:#"image"]){
[dataCell.previewBtn addTarget:self action:#selector(buttonClickedToShowImage:) forControlEvents:UIControlEventTouchUpInside];
}
else {
[dataCell.previewBtn addTarget:self action:#selector(buttonClickedToShowDocuments:) forControlEvents:UIControlEventTouchUpInside];
}
}
return dataCell ;
}
**button action of the tick mark**
-(void)checkButtonClicked:(UIButton *)sender{
CGPoint touchPoint = [sender convertPoint:CGPointZero toView:_tableView];
NSIndexPath *indexPath = [_tableView indexPathForRowAtPoint:touchPoint];
sender.tag = indexPath.row;
selectedIndexForPassing = sender.tag;
if([_selectionArray count ] == 0){
_uploadSheetBtn.enabled = NO;
if (sender.selected){
sender.selected = false;
}
else{
TCSTimeSheet * sc = self.timesheetList[selectedIndexForPassing];
_canEdit = sc.canEdit;
if([_canEdit isEqual: #"1"]){
sender.selected = true;
_uploadSheetBtn.enabled = YES;
TCSTimeSheet * sc = self.timesheetList[selectedIndexForPassing];
NSDictionary * detailsDictionary= [NSDictionary dictionaryWithObjectsAndKeys:sc.timesheetDetailId,#"timesheetDetailId",sc.scheduleEmployeeDetailId, #"scheduleDetailId",sc.lastUpdatedTime,#"lastUpdatedTime",sc.timesheetStatus,#"timesheetStatus",sc.shiftDate , #"shiftDate",sc.employeeId ,#"employeeId",nil];
[_storingArray addObject:detailsDictionary];
[_selectionArray addObject:sc.clientId];
}
}
}
else{
TCSTimeSheet * sc = self.timesheetList[selectedIndexForPassing];
if (sender.selected){
NSDictionary * detailsDictionary= [NSDictionary dictionaryWithObjectsAndKeys:sc.timesheetDetailId,#"timesheetDetailId",sc.scheduleEmployeeDetailId, #"scheduleDetailId",sc.lastUpdatedTime,#"lastUpdatedTime",sc.timesheetStatus,#"timesheetStatus",sc.shiftDate,#"shiftDate",sc.employeeId,#"employeeId",nil];
sender.selected = false;
[_storingArray removeObject:detailsDictionary];
//[_selectionArray removeAllObjects];
if([_storingArray count] == 0){
_uploadSheetBtn.enabled = NO;
[_selectionArray removeAllObjects];
}
}
else{
if([_selectionArray firstObject] == sc.clientId){
_uploadSheetBtn.enabled = YES;
sender.selected = true;
NSDictionary * detailsDictionary= [NSDictionary dictionaryWithObjectsAndKeys:sc.timesheetDetailId,#"timesheetDetailId",sc.scheduleEmployeeDetailId, #"scheduleDetailId",sc.lastUpdatedTime,#"lastUpdatedTime",sc.timesheetStatus,#"timesheetStatus",sc.shiftDate , #"shiftDate",sc.employeeId ,#"employeeId",nil];
[_storingArray addObject:detailsDictionary];
}
else{
sender.selected = false;
UIAlertView *alertCantDisply=[[UIAlertView alloc]initWithTitle:#"Can't Select" message:#"Can choose same client only" delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alertCantDisply show];
}
}
}
}
The cell will reuse, but the model will not, and the state of the view should be recorded in the model

How to receive mouseDown messages in a NSTableViewCell?

I am trying to make a table view cell that shows ratings for songs in a playlist. I have successfully created the cell so that it shows the current number of stars, and also an indication of how a new setting will be when you hover your mouse cursor over a cell to give a new rating.
The problem is that while mouseEnter, mouseExit and mouseMove works like a charm, I get no messages for mouseDown, which is required to actually change the value of the cell.
I have searched all over the Internet, but I can't find any solution to how to solve this problem anywhere. I have spent so many hours trying to sort this. I hope anyone have any answer or hint what I can do. Thank you.
The full code for the current implementation is as follows:
#import "FavouriteCellView.h"
#implementation FavouriteCellView {
NSTrackingArea *_trackingArea;
int _starsRated; //The current rating value
BOOL _hovering; //YES if the mouse is currently hovering over this cell
int _starsHovering; //The number of stars hovering, if the mouse is hovering over this cell
}
- (void)awakeFromNib {
[super awakeFromNib];
_starsRated = 1;
_hovering = NO;
_starsHovering = 0;
[self createTrackingArea];
}
- (void)createTrackingArea
{
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds options:NSTrackingMouseEnteredAndExited |NSTrackingActiveInActiveApp | NSTrackingMouseMoved owner:self userInfo:nil];
[self addTrackingArea:_trackingArea];
}
- (void)updateTrackingAreas{
[self removeTrackingArea:_trackingArea];
_trackingArea = nil;
[self createTrackingArea];
}
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// CGFloat middleX = [self bounds].size.width / 2.0f;
CGFloat middleY = [self bounds].size.height / 2.0f;
CGFloat starDivs = [self bounds].size.width / 5.0f;;
NSColor *starSelectedColor = [NSColor colorWithDeviceRed:0.8f green:0.0f blue:0.4f alpha:1.0f];
NSColor *starUnselectedColor = [NSColor colorWithDeviceRed:0.5f green:0.5f blue:0.5f alpha:1.0f];
NSColor *starHoverColor = [NSColor colorWithDeviceRed:1.0f green:0.843f blue:0.0f alpha:1.0f];
NSColor *starHoverColorSelected = [NSColor colorWithDeviceRed:0.9f green:0.843f blue:0.6f alpha:1.0f];
for (int i = 0; i < 5; i++) {
NSColor *useColor = [NSColor redColor];
if (_hovering && (i <= _starsHovering)) {
if (i <= _starsRated) {
useColor = starHoverColorSelected;
} else {
useColor = starHoverColor;
}
} else if (i <= _starsRated) {
useColor = starSelectedColor;
} else {
useColor = starUnselectedColor;
}
[self star:NSMakePoint((starDivs / 2.0f) + starDivs * i, middleY) color:useColor];
}
}
-(void)star:(NSPoint)center color:(NSColor *)color {
[color set];
CGFloat t = (2.0f * M_PI) / 10.0f;
NSBezierPath *path = [[NSBezierPath alloc] init];
CGFloat radii1 = 12.0f;
CGFloat radii2 = 4.0f;
CGFloat rot = M_PI / 2.0f;
BOOL first = YES;
for (int i = 0; i < 10; i++) {
CGFloat pointX = cos(t * i + rot) * radii1 + center.x;
CGFloat pointY = sin(t * i + rot) * radii1 + center.y;
CGFloat tempRadii = radii1;
radii1 = radii2;
radii2 = tempRadii;
if (first) {
first = NO;
[path moveToPoint:NSMakePoint(pointX, pointY)];
}
else {
[path lineToPoint:NSMakePoint(pointX, pointY)];
}
}
[path closePath];
[path fill];
/*
[[NSColor blackColor] set];
[path setLineWidth:0.25f];
[path stroke];
*/
}
-(NSView *)hitTest:(NSPoint)aPoint {
//THIS GETS CALLED
return self;
}
-(BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event {
printf("$"); //DOES NOT GET CALLED
return YES;
}
-(BOOL)acceptsFirstResponder {
printf("!"); //DOES NOT GET CALLED
return YES;
}
-(BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
printf("8"); //DOES NOT GET CALLED
return YES;
}
-(void)mouseDown:(NSEvent *)theEvent {
printf("o"); //DOES NOT GET CALLED
_starsRated = _starsHovering;
}
-(void)mouseUp:(NSEvent *)theEvent {
printf("O"); //DOES NOT GET CALLED
}
-(void)mouseEntered:(NSEvent *)theEvent {
//DOES GET CALLED
_hovering = YES;
[self setNeedsDisplay:YES];
}
-(void)mouseExited:(NSEvent *)theEvent {
//DOES GET CALLED
_hovering = NO;
[self setNeedsDisplay:YES];
}
-(void)mouseMoved:(NSEvent *)theEvent {
//DOES GET CALLED
NSPoint mouseLocation = [[self window] mouseLocationOutsideOfEventStream];
mouseLocation = [self convertPoint: mouseLocation
fromView: nil];
int newStarsHoveringValue = mouseLocation.x / ([self bounds].size.width / 5.0f);
if (newStarsHoveringValue != _starsHovering) {
_starsHovering = newStarsHoveringValue;
[self setNeedsDisplay:YES];
}
}
#end
It was a bit fiddly, but I managed to create a solution that works. I subclassed NSTableView, then overrode mouseDown with the following code:
-(void)mouseDown:(NSEvent *)theEvent {
NSPoint globalLocation = [theEvent locationInWindow];
NSPoint localLocation = [self convertPoint:globalLocation fromView:nil];
NSInteger clickedRow = [self rowAtPoint:localLocation];
if (clickedRow != -1) {
NSInteger clickedColumn = [self columnAtPoint:localLocation];
if (clickedColumn != -1) {
if (clickedColumn == 3) {
FavouriteCellView *fv = [self viewAtColumn:clickedColumn row:clickedRow makeIfNecessary:NO];
if (fv != nil) {
[fv mouseDown:theEvent];
}
return;
}
}
}
[super mouseDown:theEvent];
}
Now it works exactly like I wanted.

Preload UICollectionViewCells

I've got a Uicollectionview with about 800 cells in it which is very slow when scrollign or zooming in or out.
The Method updateVisibleCellsNow takes about 9000 ms and slows down the App.
I still set
cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
But it didn't work at all.
So i've tried to cache all the cells at viewDidLoad, cache them in an NSCache and access them from the cahce, but it seams like I am forced to user a reuseIdentifiert and can't access created Cells from the cache.
Is there any solution for this problem?
greetings,
Alex
MY Custom CollectionViewCell:
My .h File
#interface AECalendarCell : UICollectionViewCell
{
AEProjectDayItem *item;
NSIndexPath *thePath;
UILabel *lbl;
}
#property(nonatomic, strong) UILabel *lbl;
#property(nonatomic, strong) NSIndexPath *thePath;
#property(nonatomic, strong) AEProjectDayItem *item;
#property (nonatomic) CGFloat scale;
#property bool isAM;
-(void)redrawCellWithString:(NSString*)String;
#end
My .m File
#implementation AECalendarCell
#synthesize lbl, item, thePath;
-(id)initWithFrame:(CGRect)frame
{
if (self == [super initWithFrame:frame]) {
lbl = [[UILabel alloc]init];
}
return self;
}
-(void)redrawCellWithString:(NSString*)String
{
[lbl removeFromSuperview];
lbl.frame = self.contentView.bounds;
lbl.lineBreakMode = NSLineBreakByWordWrapping;
lbl.numberOfLines = 0;
if(self.scale >= 0.9)
lbl.font = [UIFont fontWithName:#"Arial" size:14];
else if(self.scale >= 0.8)
lbl.font = [UIFont fontWithName:#"Arial" size:12];
else if(self.scale >= 0.7)
lbl.font = [UIFont fontWithName:#"Arial" size:10];
else if(self.scale >= 0.6)
lbl.font = [UIFont fontWithName:#"Arial" size:8];
else if(self.scale >= 0.5)
lbl.font = [UIFont fontWithName:#"Arial" size:6];
lbl.backgroundColor = [UIColor clearColor];
lbl.textAlignment = NSTextAlignmentCenter;
if ([String isEqualToString:#""])
lbl.text = #" ";
else
lbl.text = String;
lbl.textColor = [UIColor blackColor];
if(thePath.section == 1 && thePath.item == 0)
{
CALayer *edgeBorder = [CALayer layer];
[edgeBorder setBackgroundColor:[[UIColor blackColor] CGColor]];
[edgeBorder setFrame:CGRectMake(self.bounds.size.width-2, self.bounds.size.height-2, 2, 2)];
[lbl.layer addSublayer:edgeBorder];
}
if(thePath.section == 1 && thePath.item>0)
{
CALayer *bottomBorder = [CALayer layer];
[bottomBorder setBackgroundColor:[[UIColor blackColor] CGColor]];
[bottomBorder setFrame:CGRectMake(0, self.bounds.size.height-2, self.bounds.size.width, 2)];
[lbl.layer addSublayer:bottomBorder];
}
if(thePath.section > 1 && thePath.item == 0)
{
CALayer *rightBorder = [CALayer layer];
[rightBorder setBackgroundColor:[[UIColor blackColor] CGColor]];
[rightBorder setFrame:CGRectMake(self.contentView.bounds.size.width-2, 0, 2, self.contentView.bounds.size.width)];
[lbl.layer addSublayer:rightBorder];
}
if(thePath.section > 1 && thePath.row > 1 && thePath.row %2 == 0)
{
CALayer *endofDayLayer = [CALayer layer];
[endofDayLayer setFrame:CGRectMake(self.frame.size.width-2, 0, 2, self.frame.size.width)];
if(thePath.section % 2 == 0)
[endofDayLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
else
[endofDayLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
[self.lbl.layer addSublayer:endofDayLayer];
}
[self.contentView addSubview:lbl];
}
-(void)prepareForReuse
{
[super prepareForReuse];
lbl.layer.sublayers = NULL;
[lbl removeFromSuperview];
}
Adding the Cell:
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
AECalendarCell *cell = [CV_plantabel dequeueReusableCellWithReuseIdentifier:#"identifier" forIndexPath:indexPath];
if(cell == nil)
{
cell = [[AECalendarCell alloc]init];
}
cell.thePath = indexPath;
cell.scale = scale;
cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
[DateFormatter setDateFormat:#"dd.MM.yyyy"];
NSDateFormatter *headerDateFormatter=[[NSDateFormatter alloc] init];
[headerDateFormatter setDateFormat:#"dd.MM"];
NSDate *today = [DateFormatter dateFromString:[DateFormatter stringFromDate:startDate]];
NSDate *headerDay;
if(indexPath.section == 0)
headerDay = [today dateByAddingTimeInterval:60*60*24*(indexPath.row-1)];
else
headerDay = [today dateByAddingTimeInterval:60*60*12*(indexPath.row-1)];
if(indexPath.section==0)
{
cell.backgroundColor = [UIColor grayColor];
if(indexPath.row>0)
[cell redrawCellWithString:[headerDateFormatter stringFromDate:headerDay]];
}
else if(indexPath.section == 1)
{
cell.backgroundColor = [UIColor grayColor];
if(indexPath.row == 0)
[cell redrawCellWithString:#"Name"];
else
{
if(indexPath.row % 2 == 1)
{
[cell redrawCellWithString:#"AM"];
}
else
{
[cell redrawCellWithString:#"PM"];
}
}
}
else
{
[cell redrawCellWithString:#""];
if(indexPath.row % 2 == 1)
{
cell.item = [[AEProjectDayItem alloc]initWithDate:headerDay andUser:[[[users objectAtIndex:indexPath.section-2]valueForKey:#"userID"]intValue] andisAM:YES];
}
else
{
cell.item = [[AEProjectDayItem alloc]initWithDate:headerDay andUser:[[[users objectAtIndex:indexPath.section-2]valueForKey:#"userID"]intValue] andisAM:NO];
}
//set Colors
if(indexPath.section % 2 == 0)
{
[cell setBackgroundColor:[UIColor grayColor]];
}
else
{
[cell setBackgroundColor:[UIColor darkGrayColor]];
}
//set Data
if(indexPath.item == 0)
{
if(self.currentScale >= 0.6)
[cell redrawCellWithString:[[users objectAtIndex:indexPath.section-2]valueForKey:#"name"]];
else
[cell redrawCellWithString:[[users objectAtIndex:indexPath.section-2]valueForKey:#"nachname"]];
}
//adjust row height
for(NSArray *item in projectDayItems)
{
if(indexPath.item>0)
{
if([[item valueForKey:#"datum"]isEqualToString:[DateFormatter stringFromDate:headerDay]] &&
[[item valueForKey:#"AM"]boolValue] == cell.item.isAM &&
[[item valueForKey:#"userID"]integerValue] == cell.item.theUserID &&
cell.item != NULL)
{
cell.item.projectDayId = [[item valueForKey:#"projectDayID"]integerValue];
cell.item.bereich = [item valueForKey:#"bereich"];
cell.item.project = [[AEProject alloc]initwithID:[[item valueForKey:#"projectID"]integerValue] andName:[item valueForKey:#"projectname"]];
cell.item.theClass = [item valueForKey:#"class"];
cell.item.sequenceID = [[item valueForKey:#"sequence"]integerValue];
[cell redrawCellWithString:cell.item.project.projectName];
}
else
{
[cell redrawCellWithString:cell.item.project.projectName];
}
}
}
}
//set the Accessibility Label
if(cell.item != NULL && indexPath.section > 1 && indexPath.item>0)
{
NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
[DateFormatter setDateFormat:#"EEEE, d. MMMM"];
NSString *accString;
if(cell.item.project != nil)
{
if(cell.item.isAM)
accString = [NSString stringWithFormat:#"%# Vormittag, %# für %#", [DateFormatter stringFromDate:cell.item.theDate], cell.item.project.projectName, [[users objectAtIndex:indexPath.section-2]valueForKey:#"name"]];
else
accString = [NSString stringWithFormat:#"%# Nachmittag, %# für %#", [DateFormatter stringFromDate:cell.item.theDate], cell.item.project.projectName, [[users objectAtIndex:indexPath.section-2]valueForKey:#"name"]];
cell.lbl.accessibilityLabel = accString;
}
else
{
if(cell.item.isAM)
accString = [NSString stringWithFormat:#"%# Vormittag für %#", [DateFormatter stringFromDate:cell.item.theDate], [[users objectAtIndex:indexPath.section-2]valueForKey:#"name"]];
else
accString = [NSString stringWithFormat:#"%# Nachmittag für %#", [DateFormatter stringFromDate:cell.item.theDate], [[users objectAtIndex:indexPath.section-2]valueForKey:#"name"]];
cell.lbl.accessibilityLabel = accString;
}
}
//set Layout
if(indexPath.row > 0 && indexPath.section > 1)
[self setLayoutforCell:cell];
[self setCell:cell forIndexPath:indexPath];
return cell;
}
You create your cells without identifier, you should add this line when your view is being loaded.
[self.collectionView registerClass:[AECalendarCell class] forCellWithReuseIdentifier:#"identifier"];

Weird error messages, how to fix them?

So I was just coding along, then Xcode just started going whack when I hit build and gave me all these error that I have never had before
Here is the file:
import
#import <OpenGLES/EAGLDrawable.h>
#import "EAGLView.h"
#define USE_DEPTH_BUFFER 0
// A class extension to declare private methods #interface EAGLView ()
#property (nonatomic, retain) EAGLContext *context; #property (nonatomic, assign) NSTimer *animationTimer;
- (BOOL) createFramebuffer;
- (void) destroyFramebuffer;
- (void) updateScene:(float)delta;
- (void) renderScene;
#end
#implementation EAGLView
#synthesize context; #synthesize animationTimer; #synthesize animationInterval;
// You must implement this method
+ (Class)layerClass {
return [CAEAGLLayer class]; }
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context]) {
[self release];
return nil;
}
animationInterval = 1.0 / 60.0;
CGRect rect = [[UIScreen mainScreen] bounds];
// Set up OpenGL projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0,
rect.size.width, 0, rect.size.height, -1, 1);
glMatrixMode(GL_MODELVIEW); glViewport(0, 0, rect.size.width,
rect.size.height);
// Initialize OpenGL states glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);
glEnableClientState(GL_VERTEX_ARRAY); glClearColor(0.0f, 0.0f,
0.0f, 1.0f);
// init [self initGame];
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1.0f / 60.0f;
//[sharedSoundManager playMusicWithKey:#"song" timesToRepeat:-1];
}
return self; }
-(void) initGame{
//SET GAME STATE
//0 = Menu
//1 = Gameplay
//2 = death screen
gameState = 0;
player = [[Circle alloc] init];
score = 0;
scoreString = [NSString alloc];
scoreAdder = 1;
//[self setupScore];
menu = [[Image alloc] initWithImage:[UIImage imageNamed:#"loadImage.png"]];
bk = [[Image alloc] initWithImage:[UIImage imageNamed:#"bk.png"]];
squared = [[Image alloc] initWithImage:[UIImage imageNamed:#"squared.png"]];
gameRunning = TRUE;
gameState = 0;
squares = [[Squares alloc] init];
[squares addSquare: CGPointMake(100, 100) : 0];
//font = [[AngelCodeFont alloc]initWithFontImageNamed:#"font1.png" controlFile:#"font1.fnt"
scale: 0.0f filter: nil];
// Init sound sharedSoundManager = [SingletonSoundManager sharedSoundManager]; [sharedSoundManager loadSoundWithKey:#"menu"
fileName:#"Menu" fileExt:#"mp3" frequency: 22050];
[sharedSoundManager loadBackgroundMusicWithKey:#"music" fileName:#"bkmusic" fileExt:#"aif"];
menuMusicVariable = 1;
gameMusicVariable = 1;
}
-(void) setRunning: (bool) boolean{
gameRunning = boolean; }
-(void) runContinueCountdown{
if(gameRunning == NO){
int timer = 300;
int countdownNum;
timer --;
if(timer <= 300){
if(timer > 200){
countdownNum = 3;
}
if(timer <= 200){
if(timer > 100){
countdownNum = 2;
}
}
if(timer <= 100){
if(timer >= 1){
countdownNum = 1;
}
}
if(timer == 0 && countdownNum == 1){
[self setRunning: YES];
}
} }
- (void) mainGameLoop { CFTimeInterval time; float delta; time = CFAbsoluteTimeGetCurrent(); delta = (time - lastTime);
[self updateScene:delta]; [self renderScene]; lastTime = time;
}
- (void)updateScene:(float)delta { // Update Game Logic
if(gameRunning){
if(gameState == 0){
//MENU
if(menuMusicVariable == 1){
[sharedSoundManager stopPlayingMusic];
[sharedSoundManager playSoundWithKey:#"Menu" gain:10 pitch:10 location:Vector2fMake(0, 0) shouldLoop: TRUE];
menuMusicVariable = 0;
}
[scoreLabel setHidden: YES];
} else if(gameState == 1){
//GAMEPLAY
if(gameMusicVariable == 1){
[sharedSoundManager stopPlayingMusic];
[sharedSoundManager playMusicWithKey: #"music" timesToRepeat: -1];
gameMusicVariable = 0;
}
[scoreLabel setHidden: NO];
//game is running
if([player getAlive] == true){
score = score + scoreAdder;
} else {
score = score;
}
[player move];
[self checkSquareToCircleCollisions];
[self checkSquareToSquareCollisions];
[squares update];
} else if(gameState == 2){
//DEATH SCREEN
[sharedSoundManager stopPlayingMusic];
[scoreLabel setBounds: CGRectMake(100, 100 , 100, 40)];
}
} else {
//game is puased
} }
- (void)renderScene {
// Make sure we are renderin to the frame buffer
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
// Clear the color buffer with the glClearColor which has been set glClear(GL_COLOR_BUFFER_BIT); //Render the game Scene
if(gameState == 0){
//MENU
[menu renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
} else if(gameState == 1){
//GAMEPLAY
[bk renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
[self drawScore];
[player draw];
[squares render];
//[font drawStringAt: CGPointMake(150, 100) text:#"HELLO FONTS"];
} else if(gameState ==2){
//DEATH SCREEN
[squared renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
} // Switch the render buffer and framebuffer so our scene is displayed on the screen
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES]; }
- (void)layoutSubviews {
[EAGLContext setCurrentContext:context];
[self destroyFramebuffer];
[self createFramebuffer];
[self renderScene]; }
- (BOOL)createFramebuffer {
glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
if (USE_DEPTH_BUFFER) {
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
}
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
NSLog(#"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
return NO;
}
return YES; }
- (void)destroyFramebuffer {
glDeleteFramebuffersOES(1, &viewFramebuffer);
viewFramebuffer = 0;
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
viewRenderbuffer = 0;
if(depthRenderbuffer) {
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
depthRenderbuffer = 0;
} }
- (void)startAnimation {
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self
selector:#selector(mainGameLoop) userInfo:nil repeats:YES]; }
- (void)stopAnimation {
self.animationTimer = nil; }
- (void)setAnimationTimer:(NSTimer *)newTimer {
[animationTimer invalidate];
animationTimer = newTimer; }
- (void)setAnimationInterval:(NSTimeInterval)interval {
animationInterval = interval;
if (animationTimer) {
[self stopAnimation];
[self startAnimation];
} }
-(void) setupScore{
scoreLabel = [NSString stringWithFormat:#"%d", score];
scoreLabel.frame = CGRectMake(262, 250, 100, 40);
[scoreLabel setText: scoreString];
//normally you'll want a transparent background for your label
scoreLabel.backgroundColor = [UIColor clearColor];
//you can use non-standard fonts
[scoreLabel setFont:[UIFont fontWithName:#"TimesNewRoman" size: 1.0f]];
//change the label's text color
scoreLabel.textColor = [UIColor whiteColor];
//add it to your view
scoreLabel.transform = CGAffineTransformMakeRotation(89.53);
[self addSubview:scoreLabel]; }
-(void) resetScore {
score = 0;
scoreLabel.textColor = [UIColor blackColor];
[scoreLabel release]; }
-(void)drawScore{
[scoreLabel setText: scoreString]; }
-(void) checkSquareToCircleCollisions{
NSMutableArray *array = [squares getSquares];
for(int i = 0; i < [squares getCount]; i++){
Square *s = [array objectAtIndex: i];
CGRect rect1 = [player getRect];
CGRect rect2 = [s getRect];
if (CGRectIntersectsRect(rect1, rect2)){
player.alive = NO;
gameState = 2;
}
} }
-(void) checkSquareToSquareCollisions{
NSMutableArray *array = [squares getSquares];
for(int i = 0; i < [squares getCount]; i++){
Square *s = [array objectAtIndex: 0];
Square *ss = [array objectAtIndex: i];
CGRect rect1 = [s getRect];
CGRect rect2 = [ss getRect];
if (CGRectIntersectsRect(rect1, rect2)) {
[s setDirection: [s getXDir] * -1 : [s getYDir] * -1];
[ss setDirection: [ss getXDir] * -1 : [ss getYDir] * -1];
}
} }
-(void) spawnSquares {
// FINISH METHOD
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == 0){
//MENU
UITouch *touch = [[event allTouches] anyObject];
gameState = 1;
//[self initGame];
} else if(gameState == 1){
//GAMEPLAY
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchPos = [touch locationInView:touch.view];
touchPos.y = 480 - touchPos.y;
[player setPos: touchPos];
} else if(gameState == 2){
//DEATH SCREEN
UITouch *touch = [[event allTouches] anyObject];
gameState = 0;
//[self resetScore];
[self initGame];
} }
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == 0){
//MENU
UITouch *touch = [[event allTouches] anyObject];
//[self initGame];
} else if(gameState == 1){
//GAMEPLAY
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchPos = [touch locationInView:touch.view];
touchPos.y = 480 - touchPos.y;
[player setPos: touchPos];
} else if(gameState == 2){
//DEATH SCREEN
UITouch *touch = [[event allTouches] anyObject];
}}
- (void)accelerometer:(UIAccelerometer *)accelerometer
didAccelerate:(UIAcceleration *)acceleration {
point.y = acceleration.y * 10;
point.x = acceleration.x * 10;
CGPoint pos = [player getPos];
pos = CGPointMake(pos.x + point.x, pos.y + point.y);
[player setPos: pos];
//Right - MAY HAVE TO CHANGE
if(pos.x < 0){
pos = CGPointMake(320, pos.y);
}
//left
if(pos.x < 320){
pos = CGPointMake(0, pos.y);
}
//Top
if(pos.y < 0){
pos = CGPointMake(pos.x, 460);
}
//Bottom
if(pos.x < 460){
pos = CGPointMake(pos.x, 0);
}
}
- (void)dealloc {
[self stopAnimation];
if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil];
}
[context release];
[player release];
[menu release];
[sharedSoundManager release];
[bk release];
[squared release];
[squares release];
[scoreLabel release];
[scoreString release];
[super dealloc]; }
#end // here it says: excepted } and also its excepting #end
You are missing a brace in the runContinueCountdown at the end of the second if statement.
if(timer <= 300){
if(timer > 200){
countdownNum = 3;
}
Add a brace to the end of this if statement

Remove top shadow in my grouped UITableView?

I am a little OCD and this is driving me insane. I have been messing around with these settings for a long time.
I have a UITableView grouped that I have a shadow on the top. When you tap the top cell, it removes. What gives?
I've been stressing over this for the past hour or so. Is there a simple solution for this? Or am I just going insane?
Thanks,
Coulton
EDIT:
viewDidLoad:
formTableView.backgroundColor = [UIColor clearColor];
formTableView.layer.borderColor = [UIColor clearColor].CGColor;
formTableView.separatorColor = [UIColor colorWithRed:(194.0 / 255.0) green:(194.0 / 255.0) blue:(194.0 / 255.0) alpha: 1];
Here is how I display my cells. WARNING: It's a lot of code. There's a bunch of stuff in there you will have to sort through, so sort through it at your own risk! :)
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
// What to do when you click delete.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
//RootViewController.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return [formDataOne count];
} else {
return [formDataTwo count];
}
}
//RootViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}
// Set up the cell...
NSString *cellValue;
if (indexPath.section == 0) {
cellValue = [formDataOne objectAtIndex:indexPath.row];
} else {
cellValue = [formDataTwo objectAtIndex:indexPath.row];
}
if (indexPath.section == 0) {
cell.text = #"";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.row == 0) {
addTitle = [[UITextField alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
addTitle.borderStyle = UITextBorderStyleNone;
addTitle.textColor = [UIColor blackColor]; //text color
addTitle.font = [UIFont systemFontOfSize:16.0]; //font size
addTitle.placeholder = #"Album Name"; //place holder
addTitle.backgroundColor = [UIColor clearColor]; //background color
addTitle.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
addTitle.keyboardType = UIKeyboardTypeDefault; // type of the keyboard
addTitle.returnKeyType = UIReturnKeyDone; // type of the return key
addTitle.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
addTitle.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
[cell.contentView addSubview:addTitle];
} else if (indexPath.row == 1) {
// Set up loading text and show it
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
myLabel.text = #"Private Album";
myLabel.textColor = [UIColor blackColor];
myLabel.textAlignment = UITextAlignmentLeft;
myLabel.backgroundColor = [UIColor clearColor];
myLabel.font = [UIFont fontWithName:#"Helvetica" size: 16.0];
myLabel.numberOfLines = 0;
//[myLabel sizeToFit];
privateSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[privateSwitch addTarget:self action:#selector(switchToggled:) forControlEvents: UIControlEventTouchUpInside];
[cell.contentView addSubview:privateSwitch];
//[privateSwitch setOn:NO animated:NO];
if ([howToDisplay isEqualToString:#"no"]) {
[privateSwitch setOn:NO animated:NO];
} else {
[privateSwitch setOn:YES animated:NO];
}
[cell.contentView addSubview:myLabel];
} else {
// Set up loading text and show it
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
myLabel.text = #"Comments";
myLabel.textColor = [UIColor blackColor];
myLabel.textAlignment = UITextAlignmentLeft;
myLabel.backgroundColor = [UIColor clearColor];
myLabel.font = [UIFont fontWithName:#"Helvetica" size: 16.0];
myLabel.numberOfLines = 0;
//[myLabel sizeToFit];
[cell.contentView addSubview:myLabel];
commentsSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:commentsSwitch];
[commentsSwitch setOn:YES animated:NO];
}
} else {
//cell.text = cellValue;
UILabel *labelOne = [[UILabel alloc] initWithFrame:CGRectMake(48, 12, 130, 20)];
labelOne.text = cellValue;
labelOne.textColor = [UIColor blackColor];
[labelOne setFont:[UIFont boldSystemFontOfSize:16]];
labelOne.textAlignment = UITextAlignmentLeft;
labelOne.backgroundColor = [UIColor clearColor];
//labelOne.font = [UIFont fontWithName:#"Helvetica"];
labelOne.numberOfLines = 0;
[cell.contentView addSubview:labelOne];
if (indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else if (indexPath.row == 1) {
int countFacebook = [dataCeter.connectionFacebookArray count];
if (countFacebook == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else if (indexPath.row == 2) {
//} else if (indexPath.row == 3) {
} else if (indexPath.row == 3) {
int countTumblr = [dataCeter.connectionTumblrArray count];
if (countTumblr == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else if (indexPath.row == 4) {
} else if (indexPath.row == 5) {
} else {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
}
// Set imageView with correct thumbnail
UIImage *theImage;
if ([cellValue isEqualToString:#"Facebook"]) {
theImage = [UIImage imageNamed:#"icon_small_facebook.png"];
int countFacebook = [dataCeter.connectionFacebookArray count];
NSLog(#"facebook? %d // %#", countFacebook, dataCeter.connectionFacebookArray);
if (countFacebook != 0) {
facebookSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:facebookSwitch];
[facebookSwitch setOn:YES animated:NO];
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
} else if ([cellValue isEqualToString:#"Twitter"]) {
theImage = [UIImage imageNamed:#"icon_small_twitter.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else if ([cellValue isEqualToString:#"Flickr"]) {
theImage = [UIImage imageNamed:#"icon_small_flickr.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else if ([cellValue isEqualToString:#"Tumblr"]) {
theImage = [UIImage imageNamed:#"icon_small_tumblr.png"];
int countTumblr = [dataCeter.connectionTumblrArray count];
if (countTumblr != 0) {
tumblrSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:tumblrSwitch];
[tumblrSwitch setOn:YES animated:NO];
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
} else if ([cellValue isEqualToString:#"Email"]) {
theImage = [UIImage imageNamed:#"icon_small_email.png"];
int countEmail = [dataCeter.connectionEmailArray count];
} else if ([cellValue isEqualToString:#"MMS"]) {
theImage = [UIImage imageNamed:#"icon_small_mms.png"];
int countMMS = [dataCeter.connectionSMSArray count];
} else if ([cellValue isEqualToString:#"Photostream"]) {
theImage = [UIImage imageNamed:#"icon_small_photostream.png"];
cell.accessoryType = UITableViewCellAccessoryNone;
photostreamSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:photostreamSwitch];
[photostreamSwitch setOn:YES animated:NO];
} else {
theImage = nil;
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.imageView.image = theImage;
return cell;
}
Set your table view's separator style to UITableViewCellSeparatorStyleSingleLine. It's currently being set to UITableViewCellSeparatorStyleSingleLineEtched, which gives the effect of a doubled top border on the iPhone (it looks more detailed on iOS 5, and on iOS 3.2 and 4 on the iPad).
You're not insane, it looks like there is an extra pixel in there.
Try taking out "Sharing" and see if it still happens. Curious to see if the shadow is on "Sharing" or the table itself.
If that's the case, then you know your header view has a problem, not the table view.