How to check what frameworks and methods supported by winobjc - winobjc

I tried to port a sample iOS app with a UITableView to Windows 10. In which it tries to display 100 rows with each row contains label with value as row number. Here is the code
UILabel *label = (UILabel*)[cell viewWithTag:1];
label.text = [NSString stringWithFormat:#"Name %ld", indexPath.row];
And when launched this app in windows10 i see only empty rows.
Does viewWithTag is supported?.
How do i check what api's and methods supported by winobjc? Is there any documentation available on this?

I work on the iOS bridge project at Microsoft. The problem you're seeing here has to do with cell reuse identifiers, not viewWithTag. Our Xib2Nib tool handles converting Storyboards and Xibs when you run vsimporter. Currently, Xib2Nib does not support cell reuse identifiers defined in Storyboards (although it does support cell reuse identifiers in Xibs). So when you call dequeueReusableCellWithIdentifier:forIndexPath:, the correct cell with your UILabel in it is not instantiated, which results in you getting blank cells.
There are a couple of potential solutions to this. You could build your layout programmatically in a UITableViewCell subclass and use registerClass:forCellReuseIdentifier:. You could also lay out your cell in its own xib file (separate from your Storyboard) and use registerNib:forCellReuseIdentifier:.
In either case, you should file an issue on the project on Github if you'd like to see support for cell reuse identifiers in Storyboards – Github is the best way to get in touch with our team and informs all of our prioritization decisions.
More generally, you can see what's supported and not supported by the bridge in the Visual Studio debug console; when missing or stubbed APIs are called, you'll get a message with details. We're also working on tools that will make browsing the API surface area easier.
Thanks for checking out the project!

Related

Don't Understand Apple's takeFloatValueFrom: Example

I'm no iOS guru but I know enough to build apps. I know and understand the patterns, UIKit, and Objective-C. I'm now learning Mac Development and this little bit of "Cocoa Bindings Programming Topics" has me stumped:
Take as an example a very simple application in which the values in a text field and a slider are kept synchronized. Consider first an implementation that does not use bindings. The text field and slider are connected directly to each other using target-action, where each is the other’s target and the action is takeFloatValueFrom: as shown in Figure 2. (If you do not understand this, you should read Getting Started With Cocoa.)
This example illustrates the dynamism of the Cocoa environment—the values of two user interface objects are kept synchronized without writing any code, even without compiling.
(Emphasis mine)
Huh? Wouldn't you need to create outlets? And an IBAction that goes something like
- (IBAction)takeFloatValueFrom:(id)sender {
self.slider.floatValue = [sender floatValue];
self.textField.floatValue = [sender floatValue];
}
Is this something Mac-specific? How do you actually hook up two controls with target-action in a XIB without writing any code and have their values locked?
When you're setting up an interface in Interface Builder, you can specify that it sends a message to another object whenever it changes in some way. What this example is showing is that you can hook these two objects up such that whenever the slider changes, it sends the message takeFloatValueFrom: to the text field, and vice-versa.
takeFloatValueFrom: is a method defined on NSControl, and both a text field and a slider are subclasses of NSControl.

iOS GridView with Sections

I am trying to implement my own gridview similar to KKGridView.
My gridview has extra complexity because it needs to support multiple sections with a varying amount of items / cells in each section. (See below)
It also needs to be able to handle moving one cell from section 1 to section 0 and section 0 to section 1.
I have written the UIView to display the grid but it does not support moving cells from one section to another. The question is does anybody have a gridview that supports this functionality or can advise me of the best way forward as this gridview needs to be supported in iOS 5 & iOS 6
I would try using a combination of UICollectionView, with a UICollectionViewFlowLayout along with PSTCollectionView for iOS5 compatibility.
Take a look at the UICollectionViewDelegateFlowLayout docs, I think you'll find everything you need to build a per-section custom layout as you need.
PSTCollectionView is a "open Source, 100% API compatible replacement of UICollectionView for iOS4.3+". Further, you can use UICollectionView on iOS6 and only fall back to PSTCollectionView on iOS5 devices. Take a look at the GitHub project page.
I'm using this approach in one of the apps I'm working on, and it is really simple to implement.
EDIT: The steps you'd take to make what you want would be roughly as following:
You need to download at include the PSTCollectionView in your project. For that follow the steps on the GitHub page.
In your .h file, import PSTCollectionView.h and add the following two protocols: <PSUICollectionViewDataSource, PSUICollectionViewDelegate>. Note that with this you'll use Apple's UICollectionView in iOS6 and PSTCollectionView in iOS5. Here you should also add a property for your collection view: #property (nonatomic, strong) PSUICollectionView *collectionView;
In the viewDidLoad: method, you need to have something like this:
Code:
PSUICollectionViewFlowLayout *flowLayout = [[PSUICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
[flowLayout setItemSize:CGSizeMake(91, 119)];
[flowLayout setMinimumLineSpacing:0];
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
And you'd need to implement the following methods to your liking:
Methods:
numberOfSectionsInCollectionView:
collectionView:numberOfItemsInSection:
collectionView:cellForItemAtIndexPath:
collectionView:layout:insetForSectionAtIndex:
collectionView:layout:minimumLineSpacingForSectionAtIndex:
collectionView:layout:minimumInteritemSpacingForSectionAtIndex:
Important: Don't forget to prefix every mention of UICollectionView classes with PS. For example PSUICollectionView or PSUICollectionViewLayout.
EDIT 2: For a general understanding of UICollectionView refer to this excellent tutorial.
You can use you custom cells to achieve this functionality. One Cell with 10 subViews and 2nd with 6 subView. It will work for you.
you can get the view in the cell by tags i.e 1-6 and 1-10
Try this

How to add the iOS "Open In..." feature to an app

I would like to know how to present the "Open In..." Action Sheet (iPhone) / Popover (iPad) from my app, preferably an IBAction
I would hope that it'd be similar to declaring a file type then creating the view and opening the app selected by the user, but I know it is more complicated then that.
I realize that a similar question has been asked on StackOverflow, but I cannot make sense of the answer that was accepted: How to use "open in..." feature to iOS app?, and I have found some Apple Documentation on Document Interaction Programming. But, I can't really make sense of these.
Create a UIDocumentInteractionController by using the interactionControllerWithURL: class method (pass the URL of the file you want to open in another app).
Then call either presentOpenInMenuFromRect:inView:animated: or presentOpenInMenuFromBarButtonItem:animated:. The controller takes care of presenting the popover with available apps for that file type and opening the selected app.
If you want to know when the menu was dismissed and which app was selected, you need to implement the UIDocumentInteractionControllerDelegate protocol.
omz makes some good points on how to do that in his answer, however this procedure is much easier with the introduction of new APIs in iOS 6. Here's a simple and efficient way to show the UIActionSheet Open-In-Menu in iOS 6 and up:
NSArray *dataToShare = #[contentData]; //Or whatever data you want to share - does not need to be an NSArray
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
Also, if your app is compatible with versions of iOS lower than 6.0 you may want to check if the Share Service exists:
if ([UIActivityViewController class])
Once you present the sheet, iOS will automatically handle the rest for you. It will display a beautiful uiactionsheet with icons showing each app or service the user can open / share your data with:
Note that depending on the contents of the data, iOS will show different services in the Share Sheet
EDIT: The method above shares the file content, but not the file itself. Refer to omz's answer for more on that.
I've personally never had to do this, but your answer can most certainly be found in this Apple Documentation: http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html#//apple_ref/doc/uid/TP40010410-SW1.

How do I use a RootViewController when making an app without a ViewController?

I am trying to make a simple app from a tutorial that does not have a viewController at all. All the code is in the AppDelegate. I am on xcode 4.2 and I am getting this error:
Applications are expected to have a root view controller at the end of application launch
I'm not sure how to deal with this. There are some blogs out there with fixes but none of them are working for me and I really would like to understand what is going on here. And, how to fix it.
I do have a view that contains some buttons and labels. But I have no "ViewController". The files contained in my project are: AppDelegate.h, AppDelegate.m, and Window.xib only. There is no ViewController.h, ViewController.m
** edit **
I ended up making the app from a 'view based application' instead and just moving all the logic from the app delegate to the view controller. So, I didn't really solve the problem per se. The app works now though. Thanks for the help
It's not possible to have an iOS app that doesn't have a view controller. You can always create a trivial view controller, i.e.,
[[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds].rootViewController =
[[[UIViewController alloc] init] autorelease];
It sounds like you're looking at an old tutorial. UIWindow got a rooViewController property in iOS4. I believe it became required in iOS5 to help keep controller hierarchies and view hierarchies in sync with the addition of custom container controllers (and to fix a corner case where replacing the "root controller" of a UIWindow could stop orientation changes from propagating). There was a WWDC presentation in 2011 that explained this in some detail. I think it was Session 102, Implementing UIViewController Containment.
At then end of the day, there's no good reason not to have a root view controller. Apple wants to be able to assume it's there in their APIs going forward. If the tutorial you're looking at doesn't account for that, it's broken.
While I agree that there may be workarounds, another question to address is: why do you want an app without a view? Even if it's designed to run in the background and present no visual interface, at least make a simple view showing the application name and version, a largeish icon and perhaps a status. This kind of idle screen uses very little system resources, especially when the app is backgrounded, but improves the overall experience of the app.
If you set your deployment target to 4.3 and run on the iPhone 4.3 simulator, you won't get the warning.
To install the iOS 4.3 simulator, go to Xcode > Preferences > Downloads.

iOS 4.3: Difficulty attaching graphic to an Image View

I am a relative novice who is teaching himself Objective-C on Xcode to develop some simple iPhone game apps. I have done some reading on this but fear I'm missing something basic and obvious.
I made a simple "Hello, World" and, based on opinions in various forums, I decided to do a Tic Tac Toe. I found a nice video and built a version based on that, which ran fine. However, my own interpretation is already running into trouble.
I'm using Xcode 4.0.2 on Snow Leopard. I chose a View-Based Application template and pulled a large image view onto the layout to hold a PNG called board. I put nine small image views on the large one to hold individual cells for X and O (and created some PNGs for the images). I just attached board.png to the big image view through IB so that works fine.
Next I tried to associate cell 1 with x.png by assigning it to a variable called ximg. This is all set up in the view controller's viewDidLoad method like so -- "ximg = [UIImage imageNamed:#"x.png"];". I then used the code "cell1.image = ximg;" -- also in viewDidLoad. X appeared on the board when I built and ran.
My next step was cell 2. I wanted to use a variable in a custom method this time, so I could change it in the future. I declared a method "- (void)setcell2" (bad camelCase, I know). I put the following method into my view controller implementation file:
-(void)setcell2 {
cell2.image = ximg;
}
I also added the following message to viewDidLoad -- "[self setcell2];"
As you'd guess, I was figuring that when the app loaded, viewDidLoad would send that message to setcell2, which would attach another X in the second box, but this didn't happen.
If someone could give me some idea of what I'm overlooking, I'd be gratified. Example code is appreciated but I can figure that out with time. This is not homework. Thanks for reading!
Most likely you haven't set your cell up properly in Interface Builder. Make sure you have connected the property to the outlet.