Wednesday, October 26, 2011

iOS [UITabBarController shouldAutorotateToInterfaceOrientation]

If you want to change the UITabBarController's view orientation according to device's orientation, most of time, it's suggested that you should create a subclass of UITabBarController and override the method shouldAutorotateToInterfaceOrientation. today I found that if all of the children view controllers in UITabBarController support the same orientation, then you don't need subclass UITabBarController. that means all of view controllers' shouldAutorotateToInterfaceOrientation method should return the same value for each orientation. I don't why. and didn't find any document.

Wednesday, November 10, 2010

Web Album Services: Flickr vs. Google Picasa Web Albums vs. Facebook Photos

As I’m developing an iPhone/iPad app, iShowPhoto, which is mainly used to manage web albums, so I get familiar with some of popular web album services, like Flickr, Google Picasa Web Albums, Facebook Photos, I would like share some information about these services, they may be useful when you wanna share photos.

  • Flickr: Flickr is an online photo management and sharing application, from Flickr’s web site: www.flickr.com, it has two goals:
    • help people make their photos available to the people who matter to them
    • enable new ways of organizing photos and video
         I think Flickr has already done what they want to do, it’s really a great place to store your photos and share them. On Flickr, you can upload your photos and organize them into different Set(like album, but a little different), add friends, add others’ photos to your favorite, and join a group to share photos, and so on..., anyway, there are many ways to share photos with others on Flickr, and it’s easy to find some amazing photos, Flickr is becoming a social network based on photos.
All of these features are free with a little limitation, if you are using a free account, then you can only upload 100MB and 2 videos per month, and you cannot get the original size of your photo(High resolution, > 1024 pixels). Of course you can upgrade to Pro account, now it’s $24.95/year, about $2/month, not so expensive, but almost with on limitation.
Flickr also provide a desktop tool to upload photos, it’s available for Windows and Mac. What should I say to the tool, to be honest, it’s usable, that’s all.

  • Google Picasa Web Albums: Google Picasa Web Albums is also an online photo management application, but I don’t think it’s a sharing application, although it says it does have. Using Picasa, you can upload photos with their original size, and share them with your friends.
  • Only if you have a gmail account, then you can use Picasa. it’s free for the first 1 GB, if you want more, just buy some, it’s really very cheap, 20GB, $5/year, more options can be found here:http://picasa.google.com/support/bin/answer.py?hl=en&answer=165214
Unlike Flickr, Google provides a great desktop tool for Picasa Web Albums, it’s called Google Picasa, which is really awesome, I like it, and it’s free.
  • Facebook Photos: in fact, Facebook Photos is a good place to share photos, it’s not a good place to store your photos, as the upload photos will be scaled to 720 pixels(width or height, the larger one), and all meta data in the photo will be lost. so it’s just a good place to share, but not better than Flickr.
Until now, I didn’t see any official desktop tool to manage photos. Anyway, it’s free, and you have a lot of friends here to share with them.
So, to store your photos online, I prefer Flickr and Google Picasa Web Albums, as they can keep the original photo size and meta data(like camera name, location, taken time, etc.), most of time, they’re important to you, to share your photos, I prefer Flickr and Facebook Photos.

If you know any other good web album service, please share your experience.

Thursday, July 1, 2010

What's wrong with UIScreen.applicationFrame?

I added a subview to my current UINavigationController, but I found that there is a white gap between my subview and top view about 10-20 pixel. I’m not intended to do that, and it’s ugly.

After check each views’ frame, I found that the sub view is inited with the method initWithFrame:[[UIScreen mainScreen] applicationFrame]; and UIScreen.applicationFrame.origin.y is 20, other than 0. From apple’s document, it’s said:
This property contains the screen bounds minus the area occupied by the status bar, if it is visible. Using this property is the recommended way to retrieve your application’s initial window size. The rectangle is specified in points.
but I don’t think that’s the reason of why y is 20. status bar should be at the bottom, right? anyway I changed to use [[UIScreen mainScreen] bounds], but please not that UIScreen.bounds is (0, 0, 320, 480), the height(480) may be wrong, it’s OK right now in my application.

Friday, June 25, 2010

Wired thing after adding subview to UIAlertView

There are many discussions about adding UITextField or other UIView to UIAlertView, here are some links:

  1. New info on adding text fields to alerts
  2. Custom UIAlertView (Color chooser)
  3. Add TextField or other control to UIActionSheet or UIAlertView
At first, I used the undocumented API ‘addTextFieldWithValue’, then I found that your APP may be rejected if undocumented API used. so I changed to the second way, as mentioned in Custom UIAlertView (Color chooser), it works, except one thing, look the following pictures:

This is the first time UIAlertView shows, after I click any button, it dismisses. then when it shows again, looks like this:


I don’t know why, seems cocoa touch re-layout the views again or just forget two buttons positions, as the buttons positions are almost the same as when no subviews in UIAlertView. to avoid this, I have to release the UIAlertView each time after it dismiss.

The following is the code, almost the same as Custom UIAlertView (Color chooser) :
@interface FolderAlertView : UIAlertView
{
        UITextView *errorMsg;
        UITextField *folderName;
}

@property (nonatomic, readonly) UITextView *errorMsg;
@property (nonatomic, readonly) UITextField *folderName;

- (void)clear;
- (NSString *)inputText;
- (void)warn;

@end

@implementation
FolderAlertView

@synthesize errorMsg;
@synthesize folderName;

- (id)initWithFrame:(CGRect)frame {
        if (self = [super initWithFrame:frame]) {
              
                errorMsg = [[UITextView alloc] initWithFrame:CGRectZero];
                errorMsg.backgroundColor = [UIColor clearColor];
                errorMsg.textColor = [UIColor whiteColor];
                errorMsg.text = @“illegal name“;
                errorMsg.editable = NO;
                errorMsg.font = [UIFont systemFontOfSize:14];
              
                folderName = [[UITextField alloc] initWithFrame:CGRectZero];
                folderName.backgroundColor = [UIColor whiteColor];
                folderName.clearsOnBeginEditing = YES;
                folderName.font = [UIFont systemFontOfSize:17];
                folderName.placeholder = @"Folder Name";
                folderName.adjustsFontSizeToFitWidth = YES;
                folderName.autocorrectionType = UITextAutocorrectionTypeNo;
              
                [super insertSubview:folderName atIndex:0];
                [super insertSubview:errorMsg atIndex:1];
        }
        return self;
}

- (void)setFrame:(CGRect)rect {
        [super setFrame:CGRectMake(0, 0, rect.size.width, 200)];
        self.center = CGPointMake(320/2, 460/2);
}

- (void)layoutSubviews {
        CGFloat buttonTop;
        for (UIView *view in self.subviews) {
                if ([[[view class] description] isEqualToString:@"UIThreePartButton"]) {
                        view.frame = CGRectMake(view.frame.origin.x, self.bounds.size.height - view.frame.size.height - 15,
                                                                        view.frame.size.width, view.frame.size.height);
                        buttonTop = view.frame.origin.y;
                }
        }
      
        buttonTop -= 7;
        buttonTop -= 60;
        errorMsg.frame = CGRectMake(12, buttonTop, self.bounds.size.width - 24, 60);
      
        buttonTop -= 7;
        buttonTop -= 21;
        folderName.frame = CGRectMake(12, buttonTop, self.bounds.size.width - 24, 21);
}

- (void)clear {
        folderName.text = @"";
        errorMsg.textColor = [UIColor whiteColor];
}

- (NSString *)inputText {
        return folderName.text;
}

- (void)warn {
        errorMsg.textColor = [UIColor redColor];
}

- (void)dealloc {
        [errorMsg release];
        [folderName release];
        [super dealloc];
}

@end

Create folder using SharePoint web service

You can find how to create a folder using SharePoint web service at here http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems%28v=office.12%29.aspx .
The following XML is how to create a folder under a list directly.
<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0" ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="FSObjType">1</Field>
<Field Name="BaseName">FolderA</Field>
</Method>
</Batch>

But my question is how to create a folder in another folder, you cannot set BaseName to the path, like list/folderA/folderB, as BaseName should be the folder name, cannot contain any special characters. after checking the document above, I found that if you want to update/delete a document, the field FileRef must be provided, like this:
<Batch OnError=“Continue” PreCalc=“TRUE” ListVersion=“0” ViewName=“{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}”>
<Method ID=“1” Cmd=“Delete”>
<Field Name=“ID”>3</Field>
<Field Name=“FileRef”>http://machinename/sites/siteA/listA/folderA</Field>
</Method>
</Batch>

so FileRef is a much important value for SharePoint to identify a document. then I tried to set FileRef field to the folder path when creating a folder, like this:
<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0" ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="FSObjType">1</Field>
<Field Name="BaseName">FolderB</Field>
<Field Name="FileRef">/listA/FolderA/FolderB</Field>
</Method>
</Batch>
There it is. you can see that folder B is created under folder A.

When will google merge google toolbar bookmarks and chrome bookmars?

any plan? or I have to do it manually

in reference to:

"utmx_section("Header") A fast new browser: Now available for Mac"
- Google Chrome - Get a fast new browser. For PC, Mac, and Linux (view on Google Sidewiki)

I do not use Chrome for MAC

I don't know why, after I open Chrome, the OS is freeze for a few seconds frequently.

BTW, why no version information here?

in reference to:

"utmx_section("Header") A fast new browser: Now available for Mac"
- Google Chrome - Get a fast new browser. For PC, Mac, and Linux (view on Google Sidewiki)