I have a table view with varying height, as defined in the heightForRowAtIndexPath. For some very odd reason, the image is "indented" to the right based on the height; if the height is low enough, the image is stuck to the left side of the cell, but as the height increases, the image for said cell is shifted rightward compared to other rows.
The result of this is a very poor looking list, with images floppily laid out in a zig-zag pattern depending on the height of each individual row.
The problem is revealed by this simple example:
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return (indexPath.row+1) * 50;
}
Each cell is set up (simplified) as a "Subtitle" style cell with:
// ...
cell.textLabel.text = @"foo";
cell.detailTextLabel.text = @"bar";
cell.imageView.backgroundColor = [UIColor redColor]; // for debugging; i have images with transparent bg
cell.imageView.image = anImageThatIs55x50pixelsBig;
return cell;
Any ideas? My head bleeds from the wall-love-affair.
Edit: uploaded a screen which displays this. The "image" is just a screenshot of a tiny area of the screen which makes it look a little weird, but you get the picture I'm sure: http://img28.imageshack.us/img28/549/screenshot20100311at172.png
So I'm using RegexKitLite in my iPhone app, and I'm basically grabbing out a bunch of URLs and names from within a web page. The problem is that whenever it comes across a URL with URL encoded characters like %22 for a double quote or %27 for a single quote, the captured string basically gives me a jumbled overflowed string, containing garbage and even method names.
I'm really not doing anything particularly special within the regex, just your basic "startdelimiter(.*)enddelimiter" regex.
I want to have to occasionally insert text into the UITextView text object. For example, if the user presses the "New Paragraph" button I would like to insert a double newline instead of just the standard single newline.
How can I go about such? Do i have to read the string from UITextView, mutate it, and write it back? Then how would I know where the pointer was?
Thanks
I currently have this workflow in a tab based app:
Tab1 loads...
ViewOne : UIViewController
>>
PickerView : UIViewController
>>
DetailView : UIViewController
"" means loads based on user action. I'd like navigation bars on PickerView and DetailView. PickerView just needs a cancel button in the top left of its nav bar. DetailView needs the normal navbar back button. I already have PickerView's nav bar wired up through IB and working. I'm not sure what to do with PickerView's nav bar.
PickerView is also loaded from Tab2, who's main view starts as a UINavigationController. PickerView's nav bar works fine in that case.
ViewOne should not have a navigation bar.
Any ideas?
I'm working on an animated clock application for the iPhone, and I have to pivot all the 3 nodes in the view, which I have obtained in the following code:
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
clockarm.layer.anchorPoint = CGPointMake(0.0, 0.0);
[CATransaction commit];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions];
[CATransaction setValue:[NSNumber numberWithFloat:50.0] forKey:kCATransactionAnimationDuration];
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:-60.0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
animation.delegate = self;
[clockarm.layer addAnimation:animation forKey:@"rotationAnimation"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[CATransaction commit];
The problem it's just rotating once, ie. only 360 degree and then stopping. I want to raotate the needles indefinitely. How would I do that?
I'm new to three20 and trying to find my way through the TTNavigator class.
I try to push to a new view via the URL system.
So I used openURL: animated: method which works just fine, but it's deprecated, and I know that I should use openURLAction instead, but this has no animated: parameter. Am I missing something?
I have some data like this :
1, 111, 2, 333, 45, 67, 322, 4445
NSArray *array = [[myData allKeys]sortedArrayUsingSelector: @selector(compare:)];
If I run this code, it sorted like this:
1, 111, 2,322, 333, 4445, 45, 67,
but I actually want this:
1, 2, 45, 67, 111, 322, 333, 4445
How can I implement it? thz u.
hi , iam using MFMailCompose for my application every thing works fine but iam using this code for the iPad and on the end of the mail has been written Sent From My iPhone what can i do to change it to iPad ? :D
In the method below titleForHeaderInSection, for some reason the NSLog prints out the headers twice and then the app crashes in objc_msgSend. I can't understand why this would cause the app to crash?
It would seem from research that crashes in objc_msgSend are caused by sending messages to already freed objects, but is that the case here?
My sectionNames array is populated in viewDidLoad.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSString *title = nil;
title=[sectionNames objectAtIndex:section];
NSLog(title);
return title;
}
Thanks
This is my method:
-(void) playOrRecord:(UIButton *)sender {
if (playBool == YES) {
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];
[player setNumberOfLoops:0];
[player play];
}
else if (playBool == NO) {
if ([recorder isRecording]) {
[recorder stop];
[nowRecording setImage:[UIImage imageNamed:@"NormalNormal.png"] forState:UIControlStateNormal];
[nowRecording setImage:[UIImage imageNamed:@"NormalSelected.png"] forState:UIControlStateSelected];
}
if (nowRecording == sender) {
nowRecording = nil;
return;
}
nowRecording = sender;
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
[sender setImage:[UIImage imageNamed:@"RecordingNormal.png"] forState:UIControlStateNormal];
[sender setImage:[UIImage imageNamed:@"RecordingSelected.png"] forState:UIControlStateSelected];
recorder = [[AVAudioRecorder alloc] initWithURL:fileUrl settings:recordSettings error:&error];
[recorder record];
}
}
Most of it is self explanatory; playBool is a BOOL that is YES when it is in play mode.
Everything works in the simulator however, when I run it on a device, [recorder record] returns NO. Does anyone have a clue as to why this is happening?
Hi guys,
I've just completed my first app and having tested I'm ready for submission.
However, despite numerous web searches and reading, I'm struggling to finalise the method required to enable me to have a different name on the app store to the name that appears under the app on the device home screen.
In the plist.info file there is reference to bundle display name, executable name, bundle name, bundle identifier, product name etc.
So, for example, say I would like the app store name to display as:
HELLO WORLD
and I would like the name below the icon on the device home screen to display as:
HELLO
How should I enter the data in the plist.info file to achieve the above?
Many thanks in advance for your help.
Gav.
how can i show a UIView using cocos2d with animation, i have used code like:
[[[Director sharedDirector] openGLView] addSubview:myView];
but this without any animation, so how can we do it?
Hi all
I developing a Ipad application I am trying to use Webview but not able to open the URL in webview I am using following code
NSURL *fileURL = [[[NSURL alloc] initWithString:@"http://www.google.com/"] autorelease];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:fileURL];
[webview loadRequest:requestObj];
this code working well for Iphone app not not working for Ipad app. Is anything wrong.
Thanks Amit Battan
Hi,
I'm doing something with UIImagePickerController.
It works fine and the Picture browser does open, however, I get this message. "Failed to save the videos metadata to the filesystem. Maybe the information did not conform to a plist."
What could be causing that? That is caused by this line [self presentModalViewController:self.imgPicker animated:YES]; which is activated on a button click
Snippets of the code that I have below.
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
}
- (IBAction)grabImage {
[self presentModalViewController:self.imgPicker animated:YES];
}
it's also removing images from documents directory and from resources folder. I can not understand why? does someone found the solution to this?
Hey Everyone,
I am trying to implement a TextView that is serving as a header for a ListView. I want to format it so that I have basically a title centered on the first line and then additional information on the lines following. How can I format the text/string to create this kind of formatting?
Thanks,
Rob
hi All Guy,
I'm new member of iPhone programming. i want to write app with CoreLocation and Mapkit API.
I found and added pin to current location. So far, i want to draw the circle around my location, but i didn't do that.
I'm waiting the helping from all of you.
Thanks a lot!
SinhNguyen
Hello Guys,
I can I make motionEnded work in one of my viewController inside the tabbarcontroller.
-(BOOL)canBecomeFirstResponder
{
return YES;
}
In viewDidLoad I got
[self becomeFirstResponder];
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake )
{
NSLog(@"motioned");
}
}
When I add libiphone-exif.a to snapandrun in objectiveflickr I get this error:
".objc_class_name_EXFJpeg", referenced from:
literal-pointer@__OBJC@__cls_refs@EXFJpeg in SnapAndRunViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I do not know what this means, I follow the guide to add it, add all of the .h files and the libiphone-exif.a
Is there something special I have to do?
I'm interested in learning Objective C for iPhone development. This is a topic which I realize has been covered to death. The qualifying difference is: I'd like to start learning beginning with the latest version (the most recent iPhone OS as of May, 2010 is ver. 3.2 and 4 beta is also out). I'd like to not have to wade through or unlearn legacy information.
Using the links I've found throughout related topics on Stack Overflow, I'll read a blog post or tutorial which will say one thing, but then the comments will say, "this is different now in version xyz." For example, I've found this a few times regarding memory management/garbage collection.
I assume that Apple's "getting started" doc.s will have the most recent info but many SO posts have said that those are not the most clear.
The Stanford iPhone course looks great, but how do I know if it still applies to the most recent versions?
Where should one start learning Objective C for iPhone development starting with version 3.2 or later without having as much exposure to legacy information?
Hi,
Given that the mapkit doesn't provide forward geocoding functionality today, can anyone provide help on how I can i use a search bar to return a latitude and longitude coordinate from a user inputted address today. If someone can provide sample code that would be great.
Zap
If I try to do actions over menuItems but the actions are not running as expected.
I think code below should make the menuItem rotate by 90 degrees but when I run it, the menuItem translates from its coordinates to another coordinate then returns to its original coordinate. The complete translation takes 3 seconds.
What I need is for the menuItem to rotate by 90 degrees in place within a 3 seconds duration. Please explain where I have done wrong?
CCMenuItemImage *targetE;//Globally declared
CCMenu *menu;//Globally declared
-(id)init
{
if( (self = [super init]) )
{
isTouchEnabled = YES;
CGSize windowSize = [[CCDirector sharedDirector] winSize];
targetE = [CCMenuItemImage itemFromNormalImage:@"grossinis_sister1.png" selectedImage:@"grossinis_sister1.png" target:self selector:@selector(touch:)];
menu = [CCMenu menuWithItems:targetE,nil];
id action4 = [CCRotateBy actionWithDuration:3.0 angle:90];
[menu runAction: [CCSequence actions: action4, nil]];
menu.position = ccp(windowSize.width/2 + 200, windowSize.height/2);
[self addChild: menu z:10];
}
return self;
}
@end
Thank You.
Imagine you have a normal table view where each row is an item on a conveyor belt. You will put the items in each cell of the table view but when you scroll you also want the background image (the conveyor belt) to scroll as well. How can you do this?