mkannotation automatic/default callout not happening - mkmapview

i added an annotation and in viewforannotation i set canshowcallout and selected the annotation as well but it aint getting selected...
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
currentCoordinates = newLocation.coordinate;
ParkPlaceMark *pa = [[ParkPlaceMark alloc] init];
pa.coordinate = currentCoordinates;
pa.title = #"POI";
pa.title2 = #"CUrrent Locn";
pa.subtitle = #"Drag and drop to adjust the position if necessary";
[mapView addAnnotation:pa];
[pa release];
}
- (MKAnnotationView *)mapView:(MKMapView *)map
viewForAnnotation:(ParkPlaceMark*)annotation {
MKAnnotationView *test=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"parkingloc"];
if([annotation.title caseInsensitiveCompare:#"POI"] == NSOrderedSame)
{
test.annotation = annotation;
test.userInteractionEnabled = YES;
test.draggable = YES;
// test.pinColor = MKPinAnnotationColorRed;
[test setImage:[UIImage imageNamed:#"marker3.png"]];
[test setEnabled:YES];
[test setCanShowCallout:YES];
[test setDragState:MKAnnotationViewDragStateEnding animated:YES];
[self.mapView selectAnnotation:test.annotation animated:YES];
return test;
}
}

I had added custom animation so
[self.mapView selectAnnotation:test.annotation animated:YES];
was not working . The correct code is :
[self.mapView selectAnnotation:test.annotation animated:NO];

Related

CoreDataTableViewController does not reload on return from segue

I have several CoreDataTableViewControllers that utilize the helper class from Paul Hegarty's course. Everyone of them works except this one, and I cannot see a difference.
When the table first comes up, it is correctly populated and the segue executes properly when a cell is selected. However when I hit the back button, the table displays (null), (null) everywhere.
I have tried every variant of calling [self useDocument] that I can think of, still to no avail. Any thoughts? Thanks in advance.
//
// TeamTableViewController.m
//
#import "TeamTableViewController.h"
#import "iTrackAppDelegate.h"
#import "CoreDataTableViewController.h"
#import "SchoolRecords.h"
#import "ScheduleViewController.h"
#interface TeamTableViewController ()
#property NSInteger toggle;
#end
#implementation TeamTableViewController
#synthesize iTrackContext = _iTrackContext;
#synthesize schoolSelected = _schoolSelected;
-(void) setSchoolSelected:(SchoolRecords *)schoolSelected
{
_schoolSelected = schoolSelected;
}
-(void) setITrackContext:(NSManagedObjectContext *)iTrackContext
{
if(_iTrackContext != iTrackContext){
if (!iTrackContext) {
MyCoreDataHandler* cdh =
[(iTrackAppDelegate *) [[UIApplication sharedApplication] delegate] cdh];
_iTrackContext = cdh.context;
} else {
_iTrackContext = iTrackContext;
}
}
[self useDocument];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)setupFetchedResultsController // attaches an NSFetchRequest to this UITableViewController
{
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:#"SchoolRecords"];
// no predicate because we want ALL the Athletes
request.sortDescriptors = [NSArray arrayWithObjects:
[NSSortDescriptor sortDescriptorWithKey:#"schoolName" ascending:YES],
nil];
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:self.iTrackContext
sectionNameKeyPath:nil
cacheName:nil];
__block NSInteger myCount;
int64_t delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.iTrackContext performBlock:^(void){NSError* requestError = nil;
myCount = [self.iTrackContext countForFetchRequest:request error:&requestError];
NSLog(#"In %# and count of iTrackContext = %lu", NSStringFromClass([self class]),(unsigned long)myCount);
}];
if (!myCount || myCount == 0) {
[self displayAlertBoxWithTitle:#"No Teams" message:#"Have you added athletes yet? \nPlease go to Add Athletes" cancelButton:#"Okay"];
}
});
}
- (void)useDocument
{
if (self.iTrackContext) {
[self setupFetchedResultsController];
} else {
NSString* errorText = #"A problem arose opening the search results database of Athletes.";
[self displayAlertBoxWithTitle:#"File Error" message:errorText cancelButton:#"Okay"];
}
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (!self.iTrackContext) {
MyCoreDataHandler* cdh =
[(iTrackAppDelegate *) [[UIApplication sharedApplication] delegate] cdh];
[self setITrackContext:cdh.context];
} else {
NSLog(#"In %# of %#. Getting ready to call useDocument",NSStringFromSelector(_cmd), self.class);
[self useDocument];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// If divide into sections use line below otherwise return 1.
// return [[self.fetchedResultsController sections] count];
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Do not really need this with only one section, but makes code usable if add sections later.
return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"teamInformation";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
SchoolRecords *schoolResults = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSString* titleText = schoolResults.schoolName;
cell.textLabel.text = titleText;
cell.detailTextLabel.text = [NSMutableString stringWithFormat:#"%#, %#", schoolResults.schoolCity, schoolResults.schoolState];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
# pragma navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
[self setSchoolSelected:[self.fetchedResultsController objectAtIndexPath:indexPath]];
// be somewhat generic here (slightly advanced usage)
// we'll segue to ANY view controller that has a photographer #property
if ([segue.identifier isEqualToString:#"scheduleDetailSegue"]) {
// use performSelector:withObject: to send without compiler checking
// (which is acceptable here because we used introspection to be sure this is okay)
NSLog(#"Preparing to passing school with schoolID = %#", self.schoolSelected.schoolID);
[segue.destinationViewController convenienceMethodForSettingSchool:self.schoolSelected];
}
}
- (void) displayAlertBoxWithTitle:(NSString*)title message:(NSString*) myMessage cancelButton:(NSString*) cancelText
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:myMessage
delegate:nil
cancelButtonTitle:cancelText
otherButtonTitles:nil];
[alert show];
}
#end
Well, I am not certain what the problem was. I ended up deleting the "offending" TableViewControllers in StoryBoard and recreated them. That did the trick. In retrospect, I wonder if I did not specify the wrong type of segue from my tabViewController. But I deleted it before I thought of that possibility.

Mail composer didn't display under my UIWebView

I have a MainController and detailedcontroller. When I popover the Book selection and select a Book, the detailcontroller display an UIWebView with the book articles :
#interface IpadBooksViewController : UITableViewController {
SearchResult *searchResult;
IpadArticleViewController *detailController;
IpadMainViewController *mainController;
UIPopoverController *popover;
}
Into the UIWebView, I display an Email icon and catch the scheme :
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSURL *url = [request URL];
NSString *scheme = [url scheme];
NSString *host = [url host];
if ([[url description] hasSuffix:#"next"]) {
NSLog(#"next Show");
}
BOOL isShareLinks = [host isEqualToString:#"displayShareLinks"];
BOOL isFavoriteLinks = [host isEqualToString:#"displayFavoriteLinks"];
if ([#"myappurl" isEqualToString:scheme] && (isShareLinks || isFavoriteLinks)) {
self.selectedArticleNumber = [url.path lastPathComponent];
if (isShareLinks) {
[self sendMailArticleNumber:selectedArticleNumber];
} else if (isFavoriteLinks) {
NSLog(#"ipad favorite clicked");
[self toggleFavorite:selectedArticleNumber];
Broker *broker = [[Broker alloc] init];
[broker loadProjects:self];
[broker release];
}
}
return [super webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
}
Action is supposed to display the MFMailController under my UIWebView, but nothing is displayed without error message :
- (void) sendMailArticleNumber:(NSString *)articleNumber {
MFMailComposeViewController* composer = [[MFMailComposeViewController alloc] init];
composer.mailComposeDelegate = self;
[composer setSubject:#"Article"];
NSString *messageBody = [Article fetchBody:articleNumber bookId:bookId];
[composer setMessageBody:messageBody isHTML:YES];
[self presentModalViewController:composer animated:YES];
[composer release];
}
Any help will be welcomed. I did try creating a popover, addView atIndex without success ... Let me know if you need more code.
David
I did solve the issue by loading the controller into the delegate as following :
[((PublilexAppDelegate*)[[UIApplication sharedApplication] delegate]) sendMailArticleNumber:selectedArticleNumber bookId:self.bookId];
And then into the Delegate :
- (void) sendMailArticleNumber:(NSString *)articleNumber bookId:(NSString*)bookId {
MFMailComposeViewController* composer = [[MFMailComposeViewController alloc] init];
composer.mailComposeDelegate = self;
[composer setSubject:#"Article"];
NSString *messageBody = [Article fetchBody:articleNumber bookId:bookId];
[composer setMessageBody:messageBody isHTML:YES];
[self->navigationController presentModalViewController:composer animated:YES];
[composer release];
}
And to dismiss and comeback to the previous view :
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self->navigationController dismissModalViewControllerAnimated:YES];
// [self dismissViewControllerAnimated:YES completion:nil];
// [((PublilexAppDelegate*)[[UIApplication sharedApplication] delegate]) navigateToIpadMain];
}

Proper release of UIImagePickerController

I'm a bit confused with this as I've seen way too many different variants and not sure which one is the correct way. Currently I have:
- (IBAction)pickImageFromLibrary:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
// [picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0f, 10.0f, 320.0f, 264.0f)];
self.studyView = imageView;
[imageView release];
[self.tableView setTableHeaderView:studyView];
self.fitImage = [ImageHelper image:image fitInView:studyView];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
}
studyView.image = self.fitImage;
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
I'm allocating the UIImagePickerController in the first method but wouldn't it be logical to only release it in the 2nd method when I dismiss it?
No, because it's retained when presented modally, via presentModelViewController. This is the common pattern you'll find when presenting new view controllers, whether modally, custom view controllers or not. This is fine:
- (IBAction)pickImageFromLibrary:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}

How do you get an SQLITE database (Mydb.db) to load every time you start the iPhone App?

I have an app that access a static SQLITE database when running. A user or application is not allowed to alter or update this database. However, I need to add records or change field content to keep up with changing URLs etc. I use MesaSQLite to update the single table. But when I re-open the app in Xcode Simulator, none of the changes took effect. It's as if the app did not reload the updated database.
How can I get a reload to take place? Keep in mind that I'm still covered in shrink wrap because I'm so new to coding !!!
I'm not really sure of the SQL part. but I think that you will need to reload the table content after getting the update from the database. If you post some code, I can help you better. Here's how to reload the table:
[myTable reloadData];
And you will need to update the table with the new data in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This is an IOS4.2 iPhone app. Here is the code for accessing and displaying the sort results of the database. The purpose is to use the database to sort delegates by event and state, then display the results. The displayed delegates are linked to a website. Again, the user and the app DO NOT alter the database, it's static. I use an SQLite editor to make changes and import them back into the databases' single table. I just need the table reloaded when this portion of the code runs.
I'll need to know what code and where to insert it for table reload.
Thanks for your help !!!!!
//
// delegateList.m
// foundingFathers
//
// Created by __ on 6/23/10.
// Copyright 2010 MyCompanyName. All rights reserved.
//
import "delegateList.h"
static sqlite3 *database = nil;
#implementation delegateList
#synthesize tableView;
-(void)viewDidLoad
{
nameArray = [[NSMutableArray alloc] init];
stateArray = [[NSMutableArray alloc] init];
yearsArray = [[NSMutableArray alloc] init];
contArray = [[NSMutableArray alloc] init];
indArray = [[NSMutableArray alloc] init];
confArray = [[NSMutableArray alloc] init];
constArray = [[NSMutableArray alloc] init];
urlArray = [[NSMutableArray alloc] init];
stateNameArray = [[NSMutableArray alloc] init];
eventNameArray = [[NSMutableArray alloc] init];
[self loadStateData];
[self loadEventData];
// Setup some globals
databaseName = #"mydb.db";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
// Query the database for all delegates
[self loadDataWithState:#"" andEvent:0];
}
-(void)loadStateData
{
[stateNameArray addObject:#"All States"];
[stateNameArray addObject:#"Connecticut"];
[stateNameArray addObject:#"Delaware"];
[stateNameArray addObject:#"Georgia"];
[stateNameArray addObject:#"Maryland"];
[stateNameArray addObject:#"Massachusetts"];
[stateNameArray addObject:#"New Hampshire"];
[stateNameArray addObject:#"New Jersey"];
[stateNameArray addObject:#"New York"];
[stateNameArray addObject:#"North Carolina"];
[stateNameArray addObject:#"Pennsylvania"];
[stateNameArray addObject:#"Rhode Island"];
[stateNameArray addObject:#"South Carolina"];
[stateNameArray addObject:#"Virginia"];
}
-(void)loadEventData
{
[eventNameArray addObject:#"All Events"];
[eventNameArray addObject:#"Continental Association"];
[eventNameArray addObject:#"Declaration of Independence"];
[eventNameArray addObject:#"Confederation of States"];
[eventNameArray addObject:#"US Constitution"];
}
-(IBAction)nextPressed:(id)sender
{
[self.navigationController pushViewController:nondelegateList animated:YES];
}
-(IBAction)menuPressed:(id)sender
{
[self.navigationController popToViewController:mainmenu animated:YES];
}
/*
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
return NO;
break;
default:
return YES;
break;
}
}*/
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [nameArray count]+1;
}
-(UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = #"MyIdentifier";
MyIdentifier = #"tblViewCell";
TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:#"TableCellView" owner:self options:nil];
cell = tblCell;
}
UILabel* lbl;
if (indexPath.row == 0) //table Headers
{
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
lbl = (UILabel *)[cell viewWithTag:1];
[lbl setFont:[UIFont boldSystemFontOfSize:14]];
lbl.text = #"Name";
[lbl setTextAlignment:UITextAlignmentLeft];
lbl = (UILabel *)[cell viewWithTag:2];
[lbl setFont:[UIFont boldSystemFontOfSize:14]];
lbl.text = #"State";
[lbl setTextAlignment:UITextAlignmentLeft];
} else {
//[lbl setFont:[[lbl font] fontWithSize:9]];
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
lbl = (UILabel *)[cell viewWithTag:1];
[lbl setTextAlignment:UITextAlignmentLeft];
[lbl setFont:[UIFont systemFontOfSize:14]];
lbl.text = [nameArray objectAtIndex:indexPath.row-1];
lbl = (UILabel *)[cell viewWithTag:2];
[lbl setTextAlignment:UITextAlignmentLeft];
[lbl setFont:[UIFont systemFontOfSize:14]];
lbl.text = [stateArray objectAtIndex:indexPath.row-1];
}
return cell;
}
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
return;
}
NSURL* page = [NSURL URLWithString:[urlArray objectAtIndex:indexPath.row - 1] ];
NSURLRequest* pageRequest = [NSURLRequest requestWithURL:page];
[webTitle setTitle:[nameArray objectAtIndex:indexPath.row - 1]];
[web loadRequest:pageRequest];
[self.navigationController pushViewController:webView animated:YES];
}
-(void) checkAndCreateDatabase{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:databasePath];
if(success) return;
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
//[fileManager release];
}
-(void)loadDataWithState:(NSString*)stateSearch andEvent:(int)eventSearch
{
BOOL hasEvent = (BOOL)eventSearch;
BOOL hasState = !([stateSearch isEqualToString:#"All States"] || stateSearch.length <=0);
NSString* state = stateSearch;
NSString* event = nil;
switch (eventSearch) {
case 1:
event = #"continental";
break;
case 2:
event = #"declaration";
break;
case 3:
event = #"confederation";
break;
case 4:
event = #"constitution";
break;
default:
break;
}
// Open the database from the users filessytem
if(database || sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString* sqlString = nil;
const char *sqlStatement;
if (hasEvent && hasState) {
sqlString = [[[[#"select * from founding_fathers where "stringByAppendingString:event] stringByAppendingString:#" like 'X%%' and State like '"] stringByAppendingString:state] stringByAppendingString:#"'"];
}
if (hasEvent && !hasState) {
sqlString = [[#"select * from founding_fathers where " stringByAppendingString:event] stringByAppendingString:#" like 'X%%'"];
}
if (!hasEvent && hasState) {
sqlString = [[#"select * from founding_fathers where state = '" stringByAppendingString:state] stringByAppendingString:#"'"];
}
if (!hasEvent && !hasState) {
sqlString= #"select * from founding_fathers";
}
unsigned int lengthOfMessage = [sqlString length];
char temp[lengthOfMessage + 1];
strcpy(temp, [sqlString cString]);
sqlStatement = temp;
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
[nameArray removeAllObjects];
[stateArray removeAllObjects];
[yearsArray removeAllObjects];
[contArray removeAllObjects];
[indArray removeAllObjects];
[confArray removeAllObjects];
[constArray removeAllObjects];
[urlArray removeAllObjects];
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString* dName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString* dState = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString* dYears = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
NSString* dCont = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)];
NSString* dInd = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)];
NSString* dConf = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 6)];
NSString* dConst = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 7)];
NSString* dUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 8)];
[nameArray addObject:dName];
[stateArray addObject:dState];
[yearsArray addObject:dYears];
[contArray addObject:dCont];
[indArray addObject:dInd];
[confArray addObject:dConf];
[constArray addObject:dConst];
[urlArray addObject:dUrl];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
}
-(void)viewDidUnload
{
sqlite3_close(database);
}
-(IBAction)stateSearch:(id)sender
{
pickerArray = stateNameArray;
[picker reloadAllComponents];
[picker setHidden:NO];
[doneButton setHidden:NO];
}
-(IBAction)eventSearch:(id)sender
{
pickerArray = eventNameArray;
[picker reloadAllComponents];
[picker setHidden:NO];
[doneButton setHidden:NO];
}
(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [pickerArray count];
}
(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [pickerArray objectAtIndex:row];
}
(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
}
(void) doneClicked:(id)sender
{
if (pickerArray == stateNameArray)
{
stateSearchChoice = [stateNameArray objectAtIndex:[picker selectedRowInComponent:0]];
[stateButton setTitle:stateSearchChoice];
}
if (pickerArray == eventNameArray) {
eventSearchChoice = [picker selectedRowInComponent:0];
[eventButton setTitle:[eventNameArray objectAtIndex:[picker selectedRowInComponent:0]]];
}
[picker setHidden:YES];
[doneButton setHidden:YES];
[self loadDataWithState:stateSearchChoice andEvent:eventSearchChoice];
[tableView reloadData];
}
#end

CoverFlow multiple Views

Good Morning at all,
i have a big problem in the following code and no solution, so i hope someone could
help me:
- (IBAction)goToChart {
[rootViewController switchViews];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *weiter = [UIButton buttonWithType:UIButtonTypeRoundedRect];
weiter.frame = CGRectMake(100, 400, 120, 40);
[weiter addTarget:self action:#selector(goToChart) forControlEvents:UIControlEventTouchUpInside];
NSString *ansicht = #"Weiter";
[weiter setTitle:ansicht forState:UIControlStateNormal];
[self.view addSubview:weiter];
// loading images into the queue
loadImagesOperationQueue = [[NSOperationQueue alloc] init];
NSString *imageName;
for (int i=0; i < 10; i++) {
imageName = [[NSString alloc] initWithFormat:#"cover_%d.jpg", i];
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
UIImage *aktuellesImage = imageView.image;
UIImage *scaledImage = [aktuellesImage scaleToSize:CGSizeMake(100.0f, 100.0f)];
[(AFOpenFlowView *)self.view setImage:scaledImage forIndex:i];
[imageName release];
NSLog(#"%d is the index",i);
}
[(AFOpenFlowView *)self.view setNumberOfImages:10];
}
So you can see there 10 Images in this CoverFlowView, but how could i find out the ACTUAL picture that is in front, to use this in another view??
Could someone help me, please?
Greetings Marco
-(void)openFlowView: (AFOpenFlowView *)openFlowView imageSelected:(int)index
{
AppDelegate_iPhone *appDelegate = (AppDelegate_iPhone *)[[UIApplication sharedApplication]delegate];
db_detail = (DB_data *)[self.GalleryArray objectAtIndex:index];
appDelegate.Id = db_detail.Id;
// NSLog(#"id: value is %d",db_detail.Id);
// NSLog(#"Name vlaue is: %#",db_detail.Name);
appDelegate.title = db_detail.Name;
DetailMovieViewController *ViewController = [[DetailMovieViewController alloc]init];
[self.navigationController pushViewController:ViewController animated:YES ];
[ViewController release];
[db_detail release];
}

Resources