Hi
I can see that this is something that has been troubling a lot of people:/
I have a UITabBarController that has 4 viewControllers, all of type UINavigationController.
One of the navigationControllers gets a viewController pushed onto its stack, this viewController should be presented in landscape mode/orientation.
The viewController is a graph, it is the absolutely only place in the app where landscape makes sense. (I hide the UITabBar when this is presented to not lead the user to believe this will work everywhere)
To make a UITabBarController respond correctly to changes in orientation all its viewControllers need to return the same value from the delegate method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
So to accomodate this behavior I have implemented this method in all the viewControllers belonging to the UITabBarController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL canRotate = [defaults boolForKey:@"can_rotate"];
return canRotate;
}
The "trick" is now that when my can-be-landscape viewController is pushed I do this:
- (void) viewWillAppear:(BOOL)animated {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:@"can_rotate"];
[defaults synchronize];
}
and when it is popped, I do this:
- (void) viewWillDisappear:(BOOL)animated {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:NO forKey:@"can_rotate"];
[defaults synchronize];
}
This works really well. When the viewController is on the stack I can rotate the device and the view follows.
The problem is however, that if the user taps the "back" button on the navigationBar while in landscape mode, thus popping the viewController to the previous viewController, this "old" viewController is of course also in landscape mode. To make things worse, because I set the BOOL to NO, this "old" viewController can not rotate back when I orientate the device to portrait mode.
Is there a way to update everything so that none of my other viewControllers will be in landscape mode when I pop the can-be-in-landscape mode viewController?
I am a bit worried that if this could be done from landscape to portrait it should also be possible from portrait to landscape, thus making my "hack" unnecessary.. but if it can not, then I am back to square one :/
Hope I am close and that someone could help me get there, thanks:)
I'm trying to implement GK's voice chat. I have the underlying network done over wifi instead of bluetooth. Between the simulator and my test device, I was able to accept the invitation. But immediately after, I get the call didNotStartWithParticipantID, with the following error:
Error Domain=GKVoiceChatServiceErrorDomain Code=32002 UserInfo=0x3b286f0 "Network conditions prevented connection."
Any ideas? What's causing this?
hi,
i am new Notification.what is the purpose of it...
can we use [[NSNotificationCenter defaultCenter] addObserver without postNotification,
If we can do it,how it is identified?what is the relationship between addObserver and postNotification?any one can explain in detail?
For all of you android devs out there that have the Android simulator running on your comp, you know that there are a few built in apps that are already 'installed' on your phone. I had an idea for an app that would utilize a function that is already being done in the spare parts app.
I went on to the android developer site, dug through the source code files, and found the spare parts app, and am now trying to set it up so that running it from eclipse on my machine actually runs the app in the simulator. In other words, I want to be able to make changes to and adjust some of the things in that app for my own needs. But it won't compile, because of a number of different errors.
How do I get that source code running on my local machine? Is there some special trick that I just dont know about? I thought that if I could get the source code than the rest would be easy, but it isn't being too easy. Any help here would be appreciated!!
Hi,
I want to play the podcasts those are available on itunes from my application.
Is there anyway to play podcasts within my appplication?
Thanks,
Jim.
After going into Edit mode, moving a cell, and leaving edit mode, i am left with one extra cell sitting on top of its duplicate cell while still in edit mode.
The problem has to be somewhere in here:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
NSMutableArray *array = [[fetchedResultsController fetchedObjects] mutableCopy];
id objectToMove = [[array objectAtIndex:sourceIndexPath.row] retain];
[array removeObjectAtIndex:sourceIndexPath.row];
[array insertObject:objectToMove atIndex:destinationIndexPath.row];
[objectToMove release];
for (int i=0; i<[array count]; i++) {
[(NSManagedObject *)[array objectAtIndex:i] setValue:[NSNumber numberWithInt:i] forKey:@"userOrder"];
}
[array release];
}
Any guidance greatly appreciated!
As par my app requirement, there is a couple of scenarios that I need to handle.
Scenario 1: To avoid piracy, I want to include some piece of code, whose job is sending both IMEI and Serial number of IPhone.
Scenario 2: At server side, I've a database, which has a list of both IMEI and Serial No info. Here I wanna validate both IMEI and Serial numbers. If both are not matched then I can make sure that the app is pirated.
Idea seems good. But I don't know how to handle these two scenarios in my app.
Any help is greatly appreciated.
Hi
In the contacts app, from 2.0+ , in the list you can see a border around each contact image.
(look at the image)
http://thetech24.com/wp-content/uploads/2009/10/Google-Android-2_0_thetech24.com.jpg
I have looked around the source code for the contacts app ( [http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=summary][1] ) but coundnt find it.
Thanks
[1]: http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=summary
I think I am going crazy right now. I am trying to create a spinner populated by a datatable but for some reason the dropdown list items text is not being displayed. I have looked all over and have seen other posts with people having this same problem. Can anyone help??
speciesList = (Spinner) findViewById(R.id.speciesList);
spinnerCursor = nsfdb.fetchAllSpecies();
startManagingCursor(spinnerCursor);
//String []cArrayList = new String[]{"dog", "cat", "horse", "other"};
String[] from = new String[]{"species"};
int[] to = new int[]{R.id.text1};
SimpleCursorAdapter locations = new SimpleCursorAdapter(this, R.layout.loc_row, spinnerCursor, from, to);
locations.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
speciesList.setAdapter(locations);
The spinner gets created just fine and is populated with 4 items but whenever I click on the spinner I see 4 items with no text and just radiobuttons. If I select any of them I am getting the correct selected item value but there is just no data displayed.
i'd like to change sounds when tapping on an image and drag another image over several others.
it is not working properly: the "MoveImage" is not dragable, the tapping is working outside the "TouchImage" and the sounds do not change when tapping on it.
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)))) {
[sound_E play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)))) {
[sound_F play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)))) {
[sound_D play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)))) {
[sound_Dis play];
}
}
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (CGRectContainsPoint(myMoveImage.frame, location)){
CGPoint yLocation = CGPointMake(myMoveImage.center.x,location.y);
myMoveImage.center = yLocation;
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)) {
E_NOTE.text = @"E";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)) {
F_NOTE.text = @"F";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)) {
D_NOTE.text = @"D";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)) {
Dis_NOTE.text = @"D#";
}
}
hellow all, in xcode whenever we load a mapview ,it automaticallay shows the current user location right. In my case i am showing another location on map ,such that the map loads the current location and zoomed to the location i have given .. but, the current location point was not showing (the blue one which comes automaticay..).
i have given mapView.showCurrentLocation=TRUE; but its not showing .
so could any one tells the way it works and it should say the current location mark and then zoomed to the point i have given.
Thanks
Is there any way to find out which UITableViewCell is at the top of the scroll window?
I'd like to get the current scroll position so that I can save it when the app exits. When the app gets started I want to scroll to the position it was at when it last exited.
Hi All,
I'm looking to create quite a basic app with a very simple navigation system but each of the tutorials I've come across so far go into too much depth or just involve lots of different form elements. I want to keep it as straight forward and simple as I can.
If anyone knows of any tutorials that can show me how to create a root view with say 5 or 6 sub views each displaying a form for collecting different types of data I would be very grateful. This seems like quite a simple thing to achieve but so far I havent found anything that specifically relates to what I want to do.
thanks in advance!
Hi,
This is a bit of an odd/specific one - possibly a bug?
I'm using MPMoviePlayerViewController to play a variety of files, including Enhanced Podcasts - these are audio files, but with a slideshow of images, often created using GarageBand. Until (i think) iOS 3.2 they weren't supported at all, now they are and play fine in the iPod app, but in my app the slideshow doesn't start, the full screen movie player opens, and the audio begins, but all I see is the QuickTime logo. If I scrub the track the pictures appear - and will continue to play correctly - but I see nothing if I don't scrub!
Any ideas??
On a related note, these files also include a small rectangluar button containing an (i) button on the right hand side - anybody know what it is or should do?! It does nothing for me!
How do I get the contents of the documents directory as a NSMutableArray?
I can get it as a normal NSArray, but as soon as I try to do anything with that array, my app crashes.
Thanks
Hey
is there any way to send whats in a text view (im trying to make a suggestion box) to my email address?
example
user types in the box " I think you should add twitter support"
then that is sent in the background to my email address [email protected]
then a message is popped up on the screen saying "suggestion sent"
just an example of what i mean
Any ideas, tutorial links would be greatly appreciated guys
Thanks
I would like to add a button "Vote Us" that opens App Store and brings automatically users to my app review page where they can vote my app.
How can I do it?
How do you compile a resource into the binary in XCode? That way is doesn't show up inside the application bundle as a file and it's not subject to manipulation by a user (whether good-intentioned or bad).
Is this even possible?
I'm particularly interested about this in terms of iPhone apps.
Any help is appreciated!
Hello ,guys,
My app needs to get the camera data from Iphone.
In my ImagePickerController, there is overlayView drawing realtime indications.
I use UIGetScreenImage() to get the screenshot, and I also dump overlayview to image,
then I can restore the original Image based on these two images.
if the overlayView is still, it works quite well,
but if the overlayView keeps changing, UIGetScreenImage() can not keep up with it.
For example,if the overlayView changes from a rectangle to a circle, then calling UIGetScreenImage() returns with a rectangle on top of it.
Is there a way to get the realtime camera data?
I really appreciate if someone could help.
Hi, I'm trying to modify the SurfaceView I use for doing a camera preview in order to display an overlaying square. However, the onDraw method of the extended SurfaceView is never called.
Here is the source :
public class CameraPreviewView extends SurfaceView {
protected final Paint rectanglePaint = new Paint();
public CameraPreviewView(Context context, AttributeSet attrs) {
super(context, attrs);
rectanglePaint.setARGB(255, 200, 0, 0);
rectanglePaint.setStyle(Paint.Style.FILL);
rectanglePaint.setStrokeWidth(2);
}
@Override
protected void onDraw(Canvas canvas){
canvas.drawRect(new Rect(10,10,200,200), rectanglePaint);
Log.w(this.getClass().getName(), "On Draw Called");
}
}
public class CameraPreview extends Activity implements SurfaceHolder.Callback{
private SurfaceHolder holder;
private Camera camera;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// We remove the status bar, title bar and make the application fullscreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// We set the content view to be the layout we made
setContentView(R.layout.camera_preview);
// We register the activity to handle the callbacks of the SurfaceView
CameraPreviewView surfaceView = (CameraPreviewView) findViewById(R.id.camera_surface);
holder = surfaceView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
Camera.Parameters params = camera.getParameters();
params.setPreviewSize(width, height);
camera.setParameters(params);
try {
camera.setPreviewDisplay(holder);
} catch (IOException e) {
e.printStackTrace();
}
camera.startPreview();
}
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
}
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
}
}
In a navigation-based app, LandscapeViewController only supports landscape mode (all others support both modes). I also have a "loading screen" that advises the user to rotate the phone before continuing. This way I can make sure that when my landscape view loads, that it's in landscape mode.
The problem comes when i rotate the phone to portrait mode while still showing LandscapeVC. I press the Back nagivation button to navigate up one level (to a VC that supports both landscape and portrait modes), but the upper level shows in landscape mode even though the phone is in portrait mode. I guess this is because when I left this view I was in portrait mode, I then rotated the phone while in another view, so this view has not received the notification. If I then proceed to rotate the phone to the other landscape mode (say the LandscapeVC was loaded on its right side, so I'd rotate the upper VC from portrait to the left landscape mode), it will update.
My question is: how can I notify this upper view that the phone was rotated, so when the user goes up after putting the phone in portrait mode, the upper view shows correctly?
I am interested in learning how to program game graphics for iPhone OS (3.x and beyond...). Can anyone recommend (based on personal experience) good books/websites that deal specifically with Quartz/OpenGL ES programming.
Thanks.