When I run the app in the iPhone Simulator, everything works just fine .. but with time I'll try to get my iPhone
Thread 1: Application Received
signal:" Sigbart 1"
why?
Here is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
golfbaner *detailViewController = [[golfbaner alloc] initWithNibName:#"Golfbaner" bundle:nil];
detailViewController.golf = [banenavn objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
XCode says it's HERE:
[self.navigationController pushViewController:detailViewController animated:YES];
it goes wrong
I can admit that I'm quite a beginner.... lol
seems to be u are new bee.so here i assume u would be created the golfbaner with nib file .so it would be same as filename for nibname.
Golfbaner.NIB is not with your project.//check out this
maybe like golfbaner.NIB
so use
golfbaner *detailViewController = [[golfbaner alloc] initWithNibName:#"golfbaner" bundle:nil];
Most likely is that detailViewController is nil. If you look at the console output it will tell you for certain.
The reason its nil on hardware is that the file system is case sensitive on hardware and hence
golfbaner *detailViewController = [[golfbaner alloc] initWithNibName:#"Golfbaner" bundle:nil];
"Golfbaner" != "golfbaner"
Check your nibname for case match. I suspect its "golfbaner.xib".
See iOS Objective-C Image file name/path different behavior betwewen simulator and device
As a style point class names should be capitalised otherwise it makes a class hard to separate from a variable when reading code.
It may be spelling mistake after #"Golfbaner"
just copy nibfile name and paste it.
Related
I'm trying to figure out how to get the frame of all visible windows.
I tried the following code, but it only works for the app itself other windows report {0,0,0,0}
NSArray *windowArray = [NSWindow windowNumbersWithOptions:NSWindowNumberListAllApplications | NSWindowNumberListAllSpaces];
for(NSNumber *number in windowArray){
NSLog(#"Window number: %#", number);
NSWindow *window = [[NSApplication sharedApplication] windowWithWindowNumber:[number intValue]];
NSLog(#"Window: %#", NSStringFromRect( [[window contentView] frame]));
}
Sample code is appreciated.
I figured it out:
NSMutableArray *windows = (__bridge NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
for (NSDictionary *window in windows) {
NSString *name = [window objectForKey:#"kCGWindowName" ];
CGRect bounds;
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:#"kCGWindowBounds"], &bounds);
NSLog(#"%#: %#",name,NSStringFromRect(bounds));
}
You can't create an NSWindow for a window of another application. In general, you can't access the objects of other applications except through an interface that they cooperate with, like scripting.
You can get what you're looking for using the Quartz Window Services (a.k.a. CGWindowList) API.
I'm not at all sure that the window numbers returned by Cocoa are the same as the window numbers used by that API. In fact, the docs for -[NSWindow windowNumber] specifically say "note that this isn’t the same as the global window number assigned by the window server". I'm note sure to what use you can put the window numbers returned by +[NSWindow windowNumbersWithOptions:] which are not for your application's windows.
This code works perfectly on iPad 4.3 Simulator:
NSString *source = [mediaObject objectForKey:#"source"];
NSString *videoPath = [NSString stringWithFormat:#"%#/%#", path, source];
NSURL *videoUrl = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
videoPlayer.shouldAutoplay = NO;
videoPlayer.view.frame = CGRectMake(xPos, yPos, width, height);
[backgroundImageView addSubview:videoPlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(videoPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:videoPlayer];
but it doesn't work on iPad 5 Simulator. I get a black frame with no movie nor playback controls.
I read the Apple changelog about MPMoviePlayerController, but I didn't found anything about this problem. Can you help me?
I solved the problem in this way: in my header file I wrote:
MPMoviePlayerController *moviePlayer;
with this property:
#property(nonatomic, strong) MPMoviePlayerController *moviePlayer;
and in the method in which I init the moviePlayer:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl];
self.moviePlayer = player;
It seems that assigning the player to a property "saves" the player. But don't ask me why...
You don't mention what type of URL you are trying to play, however, if it's an HTTP Live Streaming resource (.m3u8 file), then be aware that iOS 5.0 seems to have tightened up on validating the contents of the m3u8 index file.
Specifically, I've discovered that:
No individual segment can be more than twice as long as the #EXT-X-TARGETDURATION value;
The #EXTINF value (segment length in seconds) can, now, only be an integer value.
If one of these is your problem, running your application under the iOS 5.0 simulator should show a warning in the debugger console.
For HLS on iOS5, the TARGETDURATION value is really not the target duration but needs to be the maximum duration. So it should be set to the largest segment in the file.
I'm trying to read a reference to an image file out of a plist and make the image display in a detail view. although I can do this for my table view layout, I'm having trouble doing this with my DetailViewController nib file. I'm hoping someone can help me fix the problem and explain to me where I'm going wrong. What follows with the code is my explanation of what I THINK I'm doing. If you could explain to me what I'm doing wrong as much as show me what I should be doing, I'd really appreciate it. I'm trying to learn as much as trying to make things work.
I think the problem resides in two places. The first is my didSelectRowAtIndexPath method:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Get the dictionary of the selected data source.
NSDictionary *dictionary = [[[self.localSites objectAtIndex:indexPath.section]objectForKey:#"rowData"] objectAtIndex:indexPath.row];
TableDetailViewController *controller = [[TableDetailViewController alloc] initWithNibName:#"TableDetailViewController" bundle:[NSBundle mainBundle]];
controller.title = [dictionary objectForKey:#"Location"];
controller.dText = [dictionary objectForKey:#"details"];
// THIS IS WHERE THE PROBLEM IS
NSString *tiny = [dictionary objectForKey:#"thumb"];
controller.mainImage = [UIImage imageNamed:tiny];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
In the code above marked //THIS IS WHERE I THINK THE PROBLEM IS, What I'm trying to do is grab the reference to the image contained in string in the plist and use the reference to get the image. This approach works fine in my cellForRowAtIndexPath method where I use it to populate the left hand side of the table with thumbnail images referred to from my plist.
In the above code mainImage refers to a string I've tried to connect to a UIImageView outlet in my TableDetailViewController.xib through my TableDetailViewController.m file as below. This is where I think Problem number two is:
- (void)viewWillAppear:(BOOL)animated
{
[super viewDidLoad];
//This Bit says that the text contained in UITextView blurb is the string dText, which is used in my didSelectRowAtIndex method
blurb.text = dText;
//This is where I try to do the same thing by saying that UIImageView topImage is the NSString mainImage which I use in my didSelectRowAtIndex method
topImage.image = mainImage;
}
My Logic was that topImage is a UIImageView and mainImage is the string containing the image view which in my didSelectRowAtIndex method I pass the value of the key 'thumb' contained in my plist file.
However the above throws up warnings. Can anyone help?
Thanks for taking the time to read.
Ok, I managed to work this out. My mistake was to declare the pointer mainImage as a NSString instead of as a UIImage. I did this because in the .plist I am using the name of the image is contained within a string. I realised though that as I change this string for the .png file of the same name in my didSelectRowAtIndexPath method, by the time I'm passing it to mainImage it is no longer a string I'm passing, it's an image. Sorted! An easy mistake for a newb like me to make. Thought I should post as I'm sure I wont be the only one who makes this mistake.
in my project I use a NSmutablearray that I fill with UIImageView in .m (viewDidLoad)
arrayView = [[NSMutableArray alloc] initWithObjects: image1, image2, image3, nil];
but in method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
when I write
int i = 1;
[[arrayView objectAtIndex:i] setImage:image];
there is an exception that say that my array is empty...why?
Please post the rest of viewDidLoad. I want to see how image1 is initialized. The line:
arrayView = [[NSMutableArray alloc] initWithObjects: image1, image2, image3, nil];
will return an empty array if image1 is nil. You should also protect your app from crashing by not making assumptions about the data source. You shouldn't crash if the array is empty, just display an empty tableView.
[EDIT]
I just read the last comment you made in the other answer. Sounds like your imageViews are created in IB. Make sure they are connected to the image1 etc outlets in IB.
Try this instead:
if (i < [arrayView count]) {
UIImageView *imageView = [arrayView objectAtIndex:i];
imageView.image = image;
}
Separating accessing the array element (by assigning it to an actual UIImageView object) and then assigning the new image may be helpful. I've seen cases where if you stack up too many operations things get confused, especially if you are dealing with objects of different types that may or may not have the selectors you're using.
Why your array is turning up empty is another issue. Initializing it in viewDidLoad seems right. You may need to add some "protection" (as above) in your table methods to avoid accessing an empty array. Then in method like viewWillAppear:, call reloadData.
i shortly started Programming Mac OS X Applications with Cocoa, so its a realy New bee question. Sorry about this.
At first my code snippet:
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
Purchaser *actPurchaser = [tableViewDataArray objectAtIndex:row];
NSString *colID = [tableColumn identifier];
NSString *cell = [actPurchaser performSelector:NSSelectorFromString( colID)];
return cell;
}
You see i want to display all Members off Purchaser in a NSTableView, but the Program start for a long time and then fails. A look in debugger says that the Problem is the NSString, debugger says "Variable is not CFString". I've no idea whats this should/could mean, so i googled around, found some forum threads, but no one helps me.
Any Ideas? If i let out some Informations, sorry. Ask me about them!
Greetings,
Dennis
Have you checked that the -identifier method actually returns an NSString instance? Try NSLog(#"colID = %#", colID); I suspect you may not have set the identifier for some column, or that you have set an identifier which isn't a string.