I have a .xib file. I open it up with textfile or Dashcode or what ever.
Say it has 4 buttons on it. All the same but with different titles.
My goal is to change the color, font, and background image outside of xcode automatically and then import the file into xcode.
However these things are represented by a reference number that I can't seem to find any where in my project folder connecting it to the actual image, color, or font.
<reference key="IBUINormalBackgroundImage" ref="650551563"/> <!-- Button Background -->
So a button looks like this
`<!-- Button 1 -->
<object class="IBUIButton" id="580622739">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 124}, {280, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="810145050"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<reference key="IBUIFont" ref="881065587"/> <!-- Button Font Type -->
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Facebook</string> <!-- Button Name -->
<reference key="IBUIHighlightedTitleColor" ref="587412318"/>
<reference key="IBUINormalTitleColor" ref="523599070"/> <!-- Button Font Color -->
<reference key="IBUINormalTitleShadowColor" ref="457053782"/>
<reference key="IBUINormalBackgroundImage" ref="650551563"/> <!-- Button Background -->
</object>
`
EDIT: Based on some responses. What I can do is drag and drop a xib into xcode now. But when I am making a new app I want to use an existing xib but with different colors. I will use php to auto create this code file. Then just drag and drop again. I have done this for all my .h and .m and viewcontrollers. I need to figure this out for .xibs.
The xib files contain XML generated by IB in XCode. If you edit this XML, there is no guarantee that your changes won't get wiped out by IB the next time it writes the file.
But if I understand you correctly, you are trying to peek at the xib contents to get a better understanding of how to create a UI programmatically. Programmatically generated UI's are not done by writing xib files. You may get a hint about what parameters can be configured in IB, but there is a lot of content in a xib that is distracting, if that's what you are trying to do.
Previously in Xcode 3.2 and earlier, there was Interface Builder app which was functioning outside of Xcode... but now it is a part of Xcode. You can google for Interface Builder now also...But i think apple does not allow you to have Interface Builder separately....
general link : http://guides.macrumors.com/Interface_Builder
I am working on a xib decoder written in c# and even if for the moment it's not possible to edit a xib file it's possible to display it and see what it looks like. The xib parser is open-source and is a translation of the open source implementation of Cocoa called GNUstep.
Parser is available here : https://github.com/smartmobili/CocoaBuilder.
Related
I have build a TWA as described at https://developers.google.com/web/updates/2019/02/using-twa
I want to remove the bottom navigation bar. I have read that it can only be done programmatically with IMMERSIVE mode : https://developer.android.com/training/system-ui/immersive.html
So i need to add a Class associated to the activity "android.support.customtabs.trusted.LauncherActivity" and to add the hideSystemUI() code in onCreate() i guess.
How to do that ?
Here is the manifest :
....
<activity
android:name="android.support.customtabs.trusted.LauncherActivity"
android:theme="#style/Theme.LauncherActivity"
android:label="#string/app_name">
....
How to code the immersive mode for this activity ?
Using Bubblewrap
When using Bubblewrap (recommended), you will be asked which display mode the application should use as part of the init command.
If you have already initialized the application, modify twa-manifest.json, set display to fullscreen.
In AndroidManifest.xml
When building the application yourself and using the default LauncherActivity, you can get set the following meta-tag as part of the Activity definition in AndroidManifest.xml:
<meta-data android:name="android.support.customtabs.trusted.DISPLAY_MODE"
android:value="immersive" />
I one of my big projects the customer just wished to change leading font in whole app.
It is quite simple for the fonts allocated by code (I have some kind of theme system which abstracts font creation).
But the problem starts with the fonts used in XIB files. Do I have to go thorough all of them and apply change to properties manually (I have literally dozens of them)?
Are there any smart terminal commands which could do this in more efficient way (combination of ibtool, xargs, find)?
I have accomplished similar problem - extracting all strings used in XIB as mentioned here:
https://stackoverflow.com/a/7754884/229229
And I hope there is some search (and replace) patterns also for any XIB properties.
The .xib files are plain .xml files and can be simply edited.
Only non-default fonts are defined in .xib files. Simplified example:
<object class="NSTextField" id="298830314">
<object class="NSTextFieldCell" key="NSCell" id="386648753">
<object class="NSFont" key="NSSupport">
<string key="NSName">Arial-BoldMT</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
</object>
</object>
</object>
In other words, remove all <object class="NSFont"> paths to revert to default fonts.
To change all NSTextField to specific fonts, add something like:
<object class="NSFont" key="NSSupport">
<string key="NSName">Arial-BoldMT</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
</object>
to all <object class="NSTextField">.
Xcode has no build-in feature to do this automatically in batch.
EDIT (Response to comment)
Choose specific fonts by clicking on the "Font Panel..." button:
Using the Font Panel you can select any font:
I have an activity A (i want that work in background) that start activity B with code
moveTaskToBack(false);
Intent intent = new Intent(context.getActivity(), BActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity(intent);
In manifest i have
<activity android:name="ru.nekit.BActivity"
android:label="B"
android:taskAffinity="ru.nekit"/>
When start activity B and press Home button i see that there is two launcher icons
Question how can i do that wiil be only one launche icon?
Your app may have multiple activities found in your launcher based upon your manifest file and the XML attribute:
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
For each activity that you list containing this attribute, you will have another icon found within the Launcher for that activity. Make sure you only have this attribute set for the activity you want to display in the launcher.
You may also have installed multiple versions of your app when developing if you ended up changing the application name somewhere along the way. Be sure to uninstall all previous versions.
When I create a new xib in interface builder the Interface Builder Document (Versioning) development parameter is defaulting to xCode 4.1
Is there anyway to default this to xCode 4.2 - The reason I ask is I recently changed a project to use IOS 5 and 4.2 - The project was originally created in 4.1, and when I create a new xib and set the size of the view to "Form Sheet" it generates a waring:
Attribute Unavailable: Form Sheet simulated metrics are not available prior to Xcode 4.2.
I can fix the warning by changing the Document Version drop down in the property inspector to 4.2
You will have to modify directly the XCode templates :
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File Templates/User Interface - Contains templates when you choose the menu File->New...->New File...
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/User Interface - Contains templates when you choose the menu File->New...->New Project...
Edit the any xib you want by adding this inside <archive><data>:
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<real value="4200" key="NS.object.0"/>
</object>
I want to be able to download (via a NSURLConnection request) a .XIB file, and have it presented in a view. I have implemented the NSURLConnection, and surely enough, when the connection completes, I am left with a NSString of XML data representing the XIB file. Example: (just the first few lines of many)
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">800</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
ET CETERA...
I looked through the documentation, and I believe that I cannot use "initWithNibName:" because it is being retrieved from the web. What I believe I need to do is save the .XIB to the app's document directory, and then use "loadNibFile:externalNameTable:withZone:"
Essentially what I want to do is have an iPad application, and there is a small 320x480 window, where a .XIB loaded from the web can be displayed. If I can attach it locally to a ViewController all the better, but not completely necessary.
I'm just not exactly sure how I should use "loadNibFile:externalNameTable:withZone:" Can anyone give me some advice or an example?
Thanks in advance!
loadNibFile:externalNameTable:withZone: is an AppKit method, so it only works on Mac OS, not iPhone or iPad.
In SDK 3.2 you can use -[UIViewController initWithNibName:bundle:] or -[NSBundle loadNibNamed:owner:options:], depending whether or not you want the File's Owner to be a UIViewController. While you're right that you can't download a .xib and install it into your main bundle's resources, you can probably download a bundle, save it into your Documents directory, pass it to +[NSBundle bundleWithPath:], and then extract a .xib from it using initWithNibName:bundle: or loadNibNamed:owner:options.
I haven't tried this, but is seems like it should work. I'll be curious to know if it does.
I'll also be very interested to know if Apple accepts this app. It seems like this would put section 3.2.2 of the iPhone SDK Agreement to the test.
You will not be able to do this with a plain .xib file, because those need to be compiled into a binary format for use within an actual application.
If you do compile the .xib files down into a proper iPhone .nib file, you might be able to place those within an external bundle and download that bundle to the application's Documents directory. You could then create an NSBundle instance using +bundleWithPath: or the like, and pass the Nib name and bundle into a UIViewController's –initWithNibName:bundle:.