This actually could be a multipart question. But here's the first part ...
I have an array (actually in a plist) of dictionaries. Each dictionary has 3 keys in it: (title), (points), and (description).
I am trying to make a NEW array with the values of the key "title" from each dictionary in that first array.
Let me explain WHY I am doing this and maybe that will provide a better all around explanation.
I am trying to let people pick from a pre-determined list. Heck, if this was a web page it would be very simple since all I really care about are the "points" and the "Title". On a web site I could simply do a drop down combo-box with the "points" being the value and the title being the text for each row.
But this is not a web page.
So what I am trying to do here is pop out a modal picker when they click the text field. The modal picker shows the alphabetical ordered "titles" from our new array. And whichever one they select, it closes the modal view and assigns that "title" text to the UITextField which cannot be edited by the user.
I have some code to get my modal picker to pop out. But I need to feed it an array of just the "titles" of each dictionary in my real array.
Thanks in advance (and yes I am a newbie)
Is there any method or plugin available that will alert the user to upgrade an app if the version they are using is not the latest? I suppose I could ping a web service to check what the current version is and compare with the user's version and go from there. As an aside, is there a way to check the current version of the app (some property I don't know about) or do you simply have to hardcode the version as some float variable or something?
Thanks
I have an uitableview with UITableViewCellSTyleValue1 so i have a textlabel and a detail text label.
The second thing i've got is a NSMutableArray. Now i want to fill the textLabels with the even items and the detailTextlabels with the odd entries.
So for example cell one(zero) gets entry 0 and 1 cell one gets 2 and 3 and so on.
I didn't get it working until now. :(
how does one use code to do this:
produce 15 random numbers that are not in any order, and that only occur once
eg.
1 4, 2, 5, 3, 6, 8, 7, 9, 10, 13, 12, 15, 14, 11
rand() or arc4rand() can repeat some, which is not what im after.
Thanks
How do I accept data on the backside of a utility app, and then how do I let users modify that data? I've tried all sorts of tutorials, but to no avail. If you need further information let me know. Thanks in advanced.
I would like to separate my string by spaces, commas, periods (ie. punctuations). I am using:
[myString componentsSeparatedByString:@" "];
to separate by spaces, but need to be able to split by punctuations as well.
Hi,
How I could able to add a toolbar to the picker?
I want above the picker there is a toolbar with a "done" bar button item. clicking the "done" button will hide (animate) the picker offscreen (going to bottom like the keyboard)
I'm still looking for this how-to... Hope you could help me.
Thanks
* -[UIDeviceRGBColor size]: unrecognized selector sent to instance 0x31e520
2010-03-18 12:36:48.511 IChitMe[4012:207] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '** -[UIDeviceRGBColor size]: unrecognized selector sent to instance 0x31e520'
I'm getting this exception when I'm clicking on back button of UIToolBar
I have 1 NSMutableArray and I want to convert whatever data in array will be in NSString.
tell me code for that. Array is nothing but object of NSMutableArray class.
In my app I have a UITableView and I want to change the text's alignment to center (not only from the sides like this
cell.textAlignment = UITextAlignmentCenter;
but from up and down, as well).
Can you help me?
thanks in advance!
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 load 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;
}
@end
the file that I need the users information in already has a , so Is there a way that I can get the users location coordinates without using the CLLocationManagerDelegate thing?
Team,
I am trying to bring a menu in top of all visible views during runtime. This menu should be easily addable and removable dynamically in certain conditions.
To do this, I have tried adding a button view to the UIWindow as a subview during runtime.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:nil forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[window addSubview:button];
[window makeKeyAndVisible];
[window bringSubviewToFront:button];
But it doesnt worked. Also I have tried to place this button in the root view controller, but no luck again.
Edit - Note: This code is not from a UIViewController. I am trying to build a library this will be in that library code. Use case be like you could post NSNotification to enable and disable this menu dynamically during runtime.
Please suggest.
Thanks !
In Core Data, most of the time relationships are modeled bidirectional. But the docs say in another place:
It typically only makes sense to model
a to-one relationship in one
direction.
During loadView I am creating 20 UIButtons that I would like to change the title text of depending on the state of a UIPageControl.
I have a pre-save plist that is loaded into a NSArray called arrChars on the event of the current page changing, I set the buttons titles to their relevant text title from the array. The code that does this is:
for (int i = 1; i < (ButtonsPerPage + 1); i++) {
UIButton *uButton = (UIButton *)[self.view viewWithTag:i];
if(iPage == 1) {
iArrPos = (i - 1);
} else {
iArrPos = (iPage * ButtonsPerPage) + (i - 1);
}
[uButton setAlpha:0];
NSLog(@"Trying: %d of %d", iArrPos, [self.arrChars count]);
if (iArrPos >= [self.arrChars count]) {
[uButton setTitle: @"" forState: UIControlStateNormal];
} else {
NSString *value = [[NSString alloc] initWithFormat:@"%@", [self.arrChars objectAtIndex:iArrPos]];
NSLog(@"%@", value);
[uButton setTitle: [[NSString stringWithFormat:@"%@", value] forState: UIControlStateNormal];
[value release];
//////Have tried:
//////[uButton setTitle: value forState: UIControlStateNormal];
//////Have also tried:
//////[uButton setTitle: [self.arrChars objectAtIndex:iArrPos] forState: UIControlStateNormal];
//////Have also also tried:
//////[uButton setTitle: [[self.arrChars objectAtIndex:iArrPos] autorelease] forState: UIControlStateNormal];
}
[uButton setAlpha:1];
}
When setting the Title of a button it does not appear to be autoreleasing the previous title and the allocation goes up and up. What am I doing wrong?
I have been told before that tracking things by allocations is a bad way to chase leaks because as far as I can see, the object is not leaking in Instruments but my total living allocations continue to climb until I get a memory warning. If there is a better way to track there I would love to know.
I know that NSString and CFString are toll-bridge, they can convert in such a way.
CFStringRef cfStr;
NSString* anStr=(NSString*)cfStr;
however,when I convert string in such a case when dealing addressbook
NSString* homeLabel=(NSString*)kABWorkLabel;
then homeLabel is "$!!$";
the other pre-defined CFStringRef in the addressbook property is the same.
in my program,I want to get both the label and the label item's info.
NSString* label=ABMultiValueCopyLabelAtIndex(multi,i);
so how to correctly get the string of the label?
Thanks!
I want a custom class object to hold data and have somehow the feeling that creating about 80 properties is not the best way of doing it.
Most of the properties would be bool values, so i'm thinking about creating Arrays (keys / values) or (probably better) a NSDictionary attached to the object for holding the data. Does that make sense or should i stay with the properties?
Extra: Are there general pros and cons for the different approaches? And what keywords / concepts do i have to search for to find discussions about that somehow general question?
Thanks in advance
Hello!
It's the first time to ask a question!
until now, I don't need to ask qestion about my problem
because Here is the rellay good place to share and solve
my programming error(problem?)!
now, I'm having a big problem at UIImagePickerViewController
Fisrt, while My app is enconding Video Image on pckerViewcontroller,
If I push the home button to go background, My app is terminated T_T(EXC_BAD_ACCESS)
I want to keep my app alive(living) or close safely pickerview controller to be back
I'm going crazy
if there is anyone to help me, I would really appreciated
Thank you!
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
// in Init Method
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(enterBackgound:) name:UIApplicationDidEnterBackgroundNotification object:nil];
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
UIImagePickerController *pickerController = [UIImagePickerController new];
i_pc = pickerController; // "i_pc" is member instance
....
[self presentModalViewController:pickerController animated:YES];
[pickerController release];
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
while encoding some video in pckerview Contrller, Push homeButton! and return back
then my app is killed
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
// this is my code to try to solve above problem.. But It's not working
-(void)enterBackground:(NSNotification *)notification{
[self dismissModalViewControllerAnimated:YES];
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
So I've noticed some very weird behaviour from my program. Here's a simplified code snippet and then I'll explain what occurs when built and ran.
-(void)viewDidLoad {
[super viewDidLoad];
...
if (self.sampleBool) {
[self performSegueWithIdentifier:@"mySegue" sender:self];
}
else {
// do stuff
}
}
...
-(IBAction)myMethod:(UITapGestureRecognizer*)sender {
...
[self performSegueWithIdentifier:@"mySegue" sender:self];
}
The segue triggers via the UITapGestureRecognizer fine - so I know the segue is linked correctly. However, when self.sampleBool is true and performSegueWithIdentifier is called within viewDidLoad, the segue does not fire.
Anyone have any guesses? Any help or advice is appreciated.
Thanks
Hi all,
I would like to have both master and detail views visible in landscape and portrait modes.
Like how the Settings app is implemented.
I do not find any samples for this. Appreciate your help..
I am sure this is an easy question, but one that has escaped me for some time now.
Say I have a UIViewController, either defined as a root in an XIB or on a stack. At some point in my code I want to replace it with another view controller. Just flat out replace it. How would I do that?
I have tried defining the controller and assigning, but not sure what actually makes it push on the screen with the absence of a navigation controller.