Hi, I'm trying to create a single custom UITableViewCell from a xib, among other normal UITableViewCell's. I've tried quite a few varied things to no success. Can anyone help me please?
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://feeds.harvest.org/~r/greglaurietv/~5/MW4zfyeubC8/HD100307-iPod.mp4"]];
moviePlayer.scalingMode = MPMovieScalingModeNone;
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[moviePlayer play];
only audio is playing, but nothing shows up in my view.... what am i doing wrong?
I'm trying to stream a video that is stored on Amazom S3 services.
I've tried passing the url with authentication using MPMoviePlayerController but with no success.
Like this: http://theusername:[email protected]/path/to/the/video
Have anyone done this before? I would like some advices, thanks.
Alright, so the key here is I'm not using IB at all, because the View I'm working with is created programmatically. The UIView covers the lower half the screen, and has a bunch of buttons on it. However, I want to add more buttons to the UIView, without making it any larger. To do so, I want to make a UIScrollView inside the view, which will allow me to add more buttons off screen so the user can scroll to them. I think that's how it works.
self.manaView = [[[UIView alloc] initWithFrame:frame] autorelease];
self.manaView.backgroundColor = [UIColor purpleColor];
UIScrollView *scroll = [UIScrollView alloc];
scroll.contentSize = CGSizeMake(320, 400);
scroll.showsHorizontalScrollIndicator = YES;
[self.manaView addSubview:scroll];
The first part of the code iniates my UIView, which works great, but I can't figure out how to make the UIScrollView programmatically and add it to the view, and then add the buttons to it.
UIButton *ret2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
ret2.tag = 102;
ret2.frame = CGRectMake(255, 5, 60, 50);
[ret2 setTitle:@"Return" forState:UIControlStateNormal];
[ret2 addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
[scroll addSubview:ret2];
When I did that, the button simply disappeared off my screen. So How do I do this correctly? Thank you for your help!
Here is the function where I get the compiler warning, I can't seem to figure out what is causing it. Any help is appreciated.
-(void)displaySelector{
//warning on the following line:
InstanceSelectorViewController *controller = [[InstanceSelectorViewController alloc] initWithCreator:self];
[self.navController pushViewController:controller animated:YES];
[controller release];
}
Interface and implementation for the initWithCreator: method
-(InstanceSelectorViewController*)initWithCreator:(InstanceCreator*)creator;
-(InstanceSelectorViewController*)initWithCreator:(InstanceCreator*)crt{
if (self = [self initWithNibName:@"InstanceSelectorViewController" bundle:nil]) {
creator = crt;
}
return self;
}
Hi All,
I am downloading very large data from the server. I am using NSURLConnection class for getting the data.
How to implement the pause facility so that i can resume downloading where it was left ?
Thanks
Hi,
I am creating an application based on the Utility template. The main screen consists of a menu with several buttons, each of which creates a different flip-side view. In one of those flip-side views I also configured a Navigation Controller, which works perfectly as long as I have the NavigationBar activated... I can push the view but I have to use the "back" button to return to my flip-side view, which would be the root of the Navigation Controller. The problem comes if I try to go back using "popViewControllerAnimated", properly configured with a button, instead of the "back" button of the NavigationBar. My application crashes for some reason and I am not able to understand why.
I could just use the "back" button in the NavigationBar and forget about the problem, but I would prefer to have my own button in order to go back.
My app consists of the following:
My APPDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MenuViewController *menuController = [[MenuViewController alloc] initWithNibName:@"MenuView" bundle:nil];
self.menuViewController = menuController;
[menuController release];
menuViewController.view.frame = [UIScreen mainScreen].applicationFrame;
[window addSubview:[menuViewController view]];
[window makeKeyAndVisible];
return YES;
}
MenuViewController.m starting my flip-side view:
- (IBAction)showFuelUpliftView {
FuelUpliftViewController *controller = [[FuelUpliftViewController alloc]
initWithNibName:@"FuelUpliftView" bundle:nil];
controller.delegate = self;
controller.title = @"Fuel Uplift";
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[navController setNavigationBarHidden: NO];
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
[navController release];
[controller release];
}
FuelUpliftViewController.m, where I push the second view of the NavigationController with a button:
- (IBAction)showFuelUplift2View:(id)sender {
UIViewController *controller = [[UIViewController alloc] initWithNibName:@"FuelUplift2View" bundle:nil];
controller.title = @"Settings";
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
And finally, my FuelUplift2ViewController.m, where the app crashes when trying to go back:
- (IBAction)backFromFuelUplift2View {
[self.navigationController popViewControllerAnimated:YES];
}
I do not know if all this makes sense, I am currently beginning with my first application and am still learning thanks to the traditional trial an error method. Nevertheless, I cannot see the reason for this problem and would appreciate any help I can get.
Thanks very much,
Manu
I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done?
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view]))
{
NSString * error = @"Touched the TextField";
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Selection!" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
//Want to show or hide UIPickerView
}
}
I already have an allocated UIPickerView when touches occur
@interface ThirdViewController : UIViewController <UITextFieldDelegate,UIPickerViewDelegate> {
IBOutlet UIPickerView *pickerView;
}
I have a button in a custom UITableViewCell. Its UITableView is controlled by a UIViewController. I would like to return to the RootView when that button is clicked.
I am trying to use
[self.superview.navigationController popViewControllerAnimated:YES];
in the target Action of the button, which is in the UITableViewCell.m file. However, it doesn't recognize "navigationController" because it is not in the stack.
How can I return to the RootView when that button is clicked?
Hello
Currently I have an entity named "Events" in a CoreData app. "Events" has one string property named "eventName".
In the -(void)viewDidLoad I am trying to Fetch all the "Events" objects and load their "eventName" by alphabetical order into a UIPickerView.
The ultimate end goal is through the use of a textField, buttons and the pickerView being add new objects in and remove unwanted objects out. Basically turning the UIPickerView into a UITableView. Currently I am able to save objects to the CoreData store, but am not able to pull them/their properties out into the UIPickerView.
I am willing and able to share the project source code to anyone who wants it, or is willing to look at it to help out.
thanks
Chris
When converting PDF Pages into UIImages I receive memory warnings all the time.
It seems there is either some leak or something else that eats my memory.
Using instruments didn't give me any helpful details.
I'm using the following function to generate images from a pdf file:
- (UIImage*)pdfImage:(NSString*)pdfFilename page:(int)page {
CFURLRef pdfURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)pdfFilename, kCFURLPOSIXPathStyle, false);
CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfRef, page);
CGRect pdfPageSize = CGPDFPageGetBoxRect(pdfPage, kCGPDFBleedBox);
float pdfScale;
if ( pdfPageSize.size.width < pdfPageSize.size.height ) {
pdfScale = PDF_MIN_SIZE / pdfPageSize.size.width;
}
else {
pdfScale = PDF_MIN_SIZE / pdfPageSize.size.height;
}
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
pdfPageSize.size.width*pdfScale,
pdfPageSize.size.height*pdfScale,
8,
(int)pdfPageSize.size.width*pdfScale * 4,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
// CGContextClipToRect(context, pdfPageView.frame);
// CGPDFPageRetain(pdfPage);
CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(pdfPage, kCGPDFBleedBox),
CGContextGetClipBoundingBox(context));
CGContextConcatCTM(context, transform);
CGContextDrawPDFPage(context, pdfPage);
// CGPDFPageRelease (pdfPage);
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *finalImage = [UIImage imageWithCGImage:image];
CGImageRelease(image);
CGPDFDocumentRelease(pdfRef);
return finalImage;
}
I am releasing the document and everything else, so where could be the problem?
Thanks for your help!
Sorry if this has been asked before, but I'm wondering what the best memory management practice is for NSURLConnection. Apple's sample code uses -[NSURLConnection initWithRequest:delegate:] in one method and then releases in connection:didFailWithError: or connectionDidFinishLoading:, but this spits out a bunch of analyzer warnings and seems sort of dangerous (what if neither of those methods is called?).
I've been autoreleasing (using +[NSURLConnection connectionWithRequest:delegate:]), which seems cleaner, but I'm wondering--in this case, is it at ever possible for the NSURLConnection to be released before the connection has closed?
Hey guys,
I am having issues trying to get the pageControl sample code to work with rotation. I managed to get it to rotate but it does not visually loads correctly until I start to scroll (then it works fine). Any Idea on how I can fix this problem? Here is a link to the project if you want to see it in action.
This code is based off the PageControl example apple has provided.
here is the code:
#import "ScrollingViewController.h"
#import "MyViewController.h"
@interface ScrollingViewController (PrivateMethods)
- (void)loadScrollViewWithPage:(int)page;
@end
@implementation ScrollingViewController
@synthesize scrollView;
@synthesize viewControllers;
- (void)viewDidLoad
{
amount = 5;
[super viewDidLoad];
[self setupPage];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
[scrollView release];
}
- (void)dealloc
{
[super dealloc];
}
- (void)setupPage
{
NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < amount; i++) {
[controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
[controllers release];
// a page is the width of the scroll view
scrollView.pagingEnabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * amount, 200);
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
[self loadScrollViewWithPage:0];
[self loadScrollViewWithPage:1];
}
#pragma mark -
#pragma mark UIScrollViewDelegate stuff
- (void)scrollViewDidScroll:(UIScrollView *)_scrollView
{
if (pageControlIsChangingPage) {
return;
}
/*
* We switch page at 50% across
*/
CGFloat pageWidth = _scrollView.frame.size.width;
int dog = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
// pageControl.currentPage = page;
[self loadScrollViewWithPage:dog - 1];
[self loadScrollViewWithPage:dog];
[self loadScrollViewWithPage:dog + 1];
}
- (void)loadScrollViewWithPage:(int)page {
if (page < 0) return;
if (page >= amount) return;
MyViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null]) {
controller = [[MyViewController alloc] initWithPageNumber:page];
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
if (nil == controller.view.superview) {
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self setupPage];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
#pragma mark -
#pragma mark PageControl stuff
@end
Hi there,
I aint sure if this is the right place to ask or report this... but i hope someone here can help me out with the following problem
I'm currently creating an app which offers several functionalities. anyways it also includes the TTPhotoViewController which Three20 offers. Well this controller is absolutely awesome but i'm haveing some trouble after useing the TTPhotoviewcontorller, since then all content falls behind my navigationbarcontroller.
Here are some screenshots where you can see before and after opening the viewcontroller
Before : http:// img121.imageshack.us/img121/2253/fotoze.jpg
After : http:// img88.imageshack.us/img88/5899/foto1c.jpg
[remove spaces after the // ]
Hopefully you guys can help me out since i'm quite new in these things.
Thanks in advance,
Wesley
From picture i try to update UILabel at cell that i press but it update incorrect row
how can i update text correct row?
mycode when add To accessoryView it will reuse to create each row
self.info = [[UILabel alloc] initWithFrame:CGRectMake((accView.image.size.width/2.5), 0.0, accView.image.size.width/2, accView.image.size.height)];
self.info.text = @"RSS";
self.info.tag = 3;
self.info.textColor = [UIColor whiteColor];
self.info.shadowColor = [UIColor blackColor];
self.info.shadowOffset = CGSizeMake(1,1);
self.info.font = [UIFont boldSystemFontOfSize:11];
self.info.backgroundColor = [UIColor clearColor];
[cell.accessoryView addSubview:self.info];
Hi!
I'm having a problem with UIViewAnimationTransitionCurlUp and landscape mode.
In my landscape application I have a view controller that manages two fullscreen views. In the controller I have a container view for the transitions. To switch between the two views, I use a curled transition but the animation is performed as if it were in portrait mode.
I have setted the UIDeviceOrientation in info.plist, also the supported orientations to both landscape right and left. The controller returns true in shouldAutorotateToInterfaceOrientation only for landscape right and left. I have also tried to start the controller and views with 480 width and 320 height manually. I dont know where is the problema and dont know what else to try.
Could someone help me?
Thank you!
hey there,
I've got an app that records audio. I'm wondering how I can increase the gain. is there a way to normalize the audio or amplify it somehow?
thanks,
howie
I am having a problem setting the background of UITableView to a UIImageView (see below for why I am doing this), once the view is set, it works fine, and scrolls with the UITableView, but it hides the elements of the Table View.
I need to have a UIImageView as the background for a UITableView. I know this has been answered before, but the answers are to use:
[UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage.png"]];
Or something like (which I need to use):
UIImageView *background = [MainWindow generateBackgroundWithFrame:tableView.bounds];
[tableView addSubview:background];
[tableView sendSubviewToBack:background];
The reason I need to use the latter is because of my generateBackgroundWithFrame method, which takes a large image, and draws a border around that image to the dimensions specified, and clips the remainder of the image:
+ (UIImageView *) generateBackgroundWithFrame: (CGRect)frame {
UIImageView *background = [[[UIImageView alloc] initWithFrame:frame] autorelease];
background.image = [UIImage imageNamed:@"globalBackground.png"];
[background.layer setMasksToBounds:YES];
[background.layer setCornerRadius:10.0];
[background.layer setBorderColor:[[UIColor grayColor] CGColor]];
[background.layer setBorderWidth:3.0];
return background;
}
Please note: I understand that this might poorly effect performance, but I don't have the resources to go through and make those images for each potential screen in the app. Please do not answer this question with a mindless "you shouldn't do this" response. I am aware that it is possibly the wrong thing to do.
How do I show my UITableView control elements? Is there something that I am doing wrong in my delegate? Here is a simplified version:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectMake(20, 20, 261, 45)
reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
UIImage *rowBackground;
NSString *imageName = @"standAloneTVButton.png";
rowBackground = [UIImage imageNamed:imageName];
UITextView *textView =
[[UITextView alloc] initWithFrame:CGRectMake(0, 5, 300, 200)];
textView.backgroundColor = [UIColor clearColor];
textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Helvetica" size:18.0f];
Purchase *purchase =
[[PurchaseModel productsPurchased] objectAtIndex:indexPath.row];
textView.text = [purchase Title];
selectedTextView.text = textView.text;
UIImageView *normalBackground =
[[[UIImageView alloc] init] autorelease];
normalBackground.image = rowBackground;
[normalBackground insertSubview:textView atIndex:0];
cell.backgroundView = normalBackground;
[textView release];
}
return cell;
}
Hi
I'm trying to write an NSDictionary to a plist but when I open the plist no data has been written to it.
From the log my path looks correct and my code is pretty standard.
Any ideas?
NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", @"key3", nil];
NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
for (id key in dictionary) {
NSLog(@"key: %@, value: %@", key, [dictionary objectForKey:key]);
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"FormData" ofType:@"plist"];
NSLog(@"path:%@", path);
[dictionary writeToFile:path atomically:YES];
I have a navigation controller in my left portion of my split view, and in the right portion. But sometimes, for example when an item is tapped, my left side must manually set the view controller on the right side.
Where is the best place to store the split view controller instance? Pass it around to each view controller on the left side, like I do with the navigation controller? Store it in my App Delegate and then access it via a property with [[UIApplication sharedApplication] delegate].splitView?
I have a UITableViewController that I have specified as a UISearchBarDelegate. Up until now, I had programmatically added the UISearchBar to the headerView of the table, and there were no problems.
I began to run out of screen real estate, so I decided to kill my normal UINavigationController title (which was text), and added the following code, moving my SearchBar from the table to the UINavigationBar:
// (Called in viewDidLoad)
// Programmatically make UISearchBar
UISearchBar *tmpSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,45)];
tmpSearchBar.delegate = self;
tmpSearchBar.showsCancelButton = YES;
tmpSearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
tmpSearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self set_searchBar:tmpSearchBar];
[tmpSearchBar release];
self.navigationItem.titleView = [self _searchBar];
This code works as expected - my UINavigationBar is now a UISearchBar.
However, my delegate method:
/** Only show the cancel button when the keyboard is displayed */
- (void) searchBarDidBeginEditing:(UISearchBar*) lclSearchBar
{
lclSearchBar.showsCancelButton = YES;
}
...is no longer being called. I've breakpointed, and I've confirmed that the UISearchBar's delegate is indeed self, the view controller. Oddly, this delegate method is still called just fine:
/** Run the search and resign the keyboard */
- (void) searchBarSearchButtonClicked:(UISearchBar *)lclSearchBar
{
_deepSearchRan = NO;
[self runSearchForString:[[self _searchBar] text] isSlowSearch:NO];
[lclSearchBar resignFirstResponder];
}
Any ideas why UINavigationBar is swallowing my delegate calls?? What am I missing?
Hey Everyone,
So i'm building a webView into my application to show the contents of a URL that I am passing from a selection in a UITableView. I know the UIWebView is loading content properly because if you hard code say http://www.google.ca into the NSURL then it loads fine, however when I'm passing the URL that I parsed from an RSS feed back from the UITableView it won't load the URL properly. I tried the debugger and the URL is coming out as nil right before I try and parse it, however I can use NSLog to print the value of it out to the console.
here's the code in my UIViewController that has my UIWebView
#import <UIKit/UIKit.h>
@interface ReadFeedWebViewController : UIViewController
{
NSString *urlToGet;
IBOutlet UIWebView *webView;
}
@property(nonatomic, retain) IBOutlet UIWebView *webView;
@property(nonatomic, retain) NSString *urlToGet;
@end
Here's the code for my implementation's viewDidLoad method...
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Url inside Web View Controller - %@", urlToGet);
NSURL *url = [NSURL URLWithString:urlToGet];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
}
Once again, I can print the URL to NSLog fine and if I hard code the URL into the NSURL object then it will load fine in the UIWebView. Here is where I'm setting the value in my UITableViewController...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ReadFeedWebViewController *extendedView = [[ReadFeedWebViewController alloc] init];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
extendedView.urlToGet = [[stories objectAtIndex: storyIndex] objectForKey:@"link"];
//NSLog([[stories objectAtIndex: storyIndex] objectForKey:@"summary"]);
NSLog([[stories objectAtIndex: storyIndex] objectForKey:@"link"]);
[self.navigationController pushViewController:extendedView animated:YES];
[extendedView release];
}
However, since I can print the value using NSLog in the extendedView view controller I know it's being passed properly. Cheers
Hello,
I've developed an app for a client and would like to give him an access to my iTunesConnect in order to access to the download stat for his application.
The problem is that if I create a new user and set permission to only see reports, he will be able to get all stats...
And I don't want to get stats manually each day.
Do you have an idea ?
Thanks
Hey I am using the http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/
wrapper .
My code is this :
- (IBAction)UpdateButtonPressed:(id)sender
{
Sqlite *sqlite = [[Sqlite alloc] init];
NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@"Money"ofType:@"sqlite"];
if (![sqlite open:writableDBPath])
return;
NSArray *query = [sqlite executeQuery:@"UPDATE UserAccess SET Answer ='Positano';"];
NSDictionary *dict = [query objectAtIndex:2];
NSString *itemValue = [dict objectForKey:@"Answer"];
NSLog(@"%@",itemValue);
}
Answer is the Column name , UserAccess the table name .
the column is at 3rd place in the table
What am I doing wrong why is it crashing ???