How to read facet facet_ranges in grails? - grails

A.<lst name="Age">
<int name="0">2</int>
<int name="2">1</int>
<int name="6">1</int>
<int name="9">1</int>
</lst>
</lst>
B.<lst name="facet_ranges">
<lst name="Age">
<lst name="counts">
<int name="0">3</int>
<int name="6">1</int>
<int name="9">1</int>
</lst>
<long name="gap">3</long>
<long name="start">0</long>
<long name="end">51</long>
</lst>
</lst>
i fired one RANGE query to solr database... it gives an Answer..A and B
But I am not able to read B part of answer. which is wanted to display on page
i am using grails
Help me out
thank You!!

Check QueryResponse getFacetRanges which should return you the range facet responses.
getFacetRanges().get(0) should return you RangeFacet
RangeFacet getCounts() return you RangeFacet.Count which can be used to get the range and the value.

Related

SOLR exact match results not matching

Hi I have a text_exact fieldType (field is text_ex) that has KeywordTokenizerFactory for matching against exact queries. For example, searching for sale gives results that contain the term sale, specifically. When I run the query like this text_ex:sale, the number of results were found to be 28, where as when I run the same query using a switch-query parser (defined in request handler), I get the number of results as 18, even though the parsed query is same as text_ex:sale in the switch query fq. Can anyone help me debug this issue? I suppose there is some inconsistency in the the way the query is parsed for exact case being true or false. I am not sure.
Here is my schema definition:
<fieldType name="text_exact" class="solr.TextField" omitNorms="false">
<analyzer type="index" omitTermFreqAndPositions="false">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.WordDelimiterGraphFilterFactory"
generateWordParts="1"
generateNumberParts="0"
catenateWords="0"
catenateNumbers="0"
catenateAll="1"
splitOnCaseChange="0"
splitOnNumerics="0"/>
</analyzer>
<analyzer type="query">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.WordDelimiterGraphFilterFactory"
generateWordParts="0"
generateNumberParts="0"
catenateWords="0"
catenateNumbers="0"
catenateAll="1"
splitOnCaseChange="0"
splitOnNumerics="0"/>
</analyzer>
</fieldType>
And here is my solrconfig.xml details:
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="exact">false</str>
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="defType">edismax</str>
<str name="qf">
displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2
categoryName^8 reportOwner^2 reportDetailsNameColumn^5
</str>
<str name="pf2">
displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2
categoryName^8 reportOwner^2 reportDetailsNameColumn^5
</str>
<str name="pf3">
displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2
categoryName^8 reportOwner^2 reportDetailsNameColumn^5
</str>
<str name="tie">1</str>
<str name="mm">100%</str>
<int name="ps2">3</int>
<int name="ps3">9</int>
<int name="qs">0</int>
<str name="df">text</str>
<str name="q.alt">*:*</str>
<str name="sort">score desc, averageRating desc, lastOneWeekCount desc</str>
<str name="bq">
query({!boost b=20}approved:"yes")
</str>
</lst>
<lst name="appends">
<str name="fq">{!switch case.false=*:* case.true=text_ex:$${q} v=$exact}</str>
</lst>
</requestHandler>
And here is the parsed query when I did exact search using the request handler:
"filter_queries":["{!switch case.false=\"*:*\" case.true=\"text_ex:sale\" v=$exact}"],
"parsed_filter_queries":["text_ex:sale"]
And here is the parsed query when the query text_ex:sale is run:
"filter_queries": [
"{!switch case.false=\"*:*\" case.true=\"text_ex:text_ex:sale\" v=$exact}"
],
"parsed_filter_queries": [
"MatchAllDocsQuery(*:*)"
]
Also I have noticed that enclosing a query within double quotes is throwing a syntax error. Any suggestions on how to resolve this issue?. Thanks in advance.
Here is the error message:
"error": {
"msg": "org.apache.solr.search.SyntaxError: Expected identifier at pos 53 str='{!switch case.false=\"*:*\" case.true=\"text_ex:text_ex\":sale\"\" v=$exact}'",
"code": 400
}

Rails - How to use solr SuggestComponent with sunspot

I am using sunspot_rails gem for using Solr search library with Rails. I am trying to show suggestions for users when they enter search terms in my application like this
But I can't get the SuggestComponent working with sunspot. I referred this guide for suggest component and added the following to solrconfig.xml
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">name</str>
<str name="weightField">price</str>
<str name="contextField">cat</str>
<str name="suggestAnalyzerFieldType">string</str>
<str name="buildOnStartup">false</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
When I try the context filtering suggest query
http://localhost:8982/solr/development/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&wt=json&suggest.q=c&suggest.cfq=memory
I am getting an empty response
{
"responseHeader":{
"status":0,
"QTime":43
},
"command":"build",
"suggest":{
"mySuggester":{
"c":{
"numFound":0,
"suggestions":[
]
}
}
}
}
Any idea what am I doing wrong? Can anyone help me how to use SuggestComponent with sunspot gem? Thanks in advance
You don't need to use solr's suggest component. you just need to ensure that your solr gives back results for partial keyword search which can be done by adding the edge Ngram or Ngram filter factories(loads of tutorials for that), while you do it ensure you use bundle exec susnspot:solr:start since that will use the configuration saved in your codebase. Then you can use Twitter typeahead to implement auto complete.

Sunspot/rails configuration for multi-core (for different language docs) Solr 5 in one environment

I create two cores for English and Japanese docs by Solr 5.1, and am wondering how to set up Sunspot/Rails to choose a core depending on locale selection from my rails app.
The default sunspot.yml shows a setting of one core for each production, development, and test environment, but in my case, there are two cores in one environment.
Is it possible to handle multiple cores under one environment by Sunspot?
Using URL, I can query these cores by different languages as below, so still look for a configuration to select core by locale of an user.
server:port/solr/#/EN_core/query?q=text
server:port/solr/#/JP_core/query?q='テキスト'
I figure out how to index multilingual documents in a single Solr instance and search the indexed documents by a specified language from sunspot/rails. This method uses different fields instead of cores for different languages, so it is not a direct answer to my question, but a working example to deal with multilingual documents by sunspot/solr/rails.
For example, index/search field is “description” of Entry model. Some entries have descriptions in English and the others have in Japanese. I use the language detection during the index of solr (https://cwiki.apache.org/confluence/display/solr/Detecting+Languages+During+Indexing) and copyField to deal with sunspot's behavior to add “_text” to the searchable fields.
Add empty string fields “descption_en” and “desctipion_jp” to the Entry model by rails migration commands. May sound strange but these empty fields enable sunspot to search the documents either by English or Japanese. The commands may be like below, but it took quite a lot of time for > 10 million records. I should consider other methods here - https://www.onehub.com/blog/2009/09/15/adding-columns-to-large-mysql-tables-quickly/
rails generate migration AddLanguageHolderToEntry description_en:string description_jp:string
rake db:migrate
Add searchable to the Entry model
class Entry < ActiveRecord::Base
searchable do
text :description, :description_en, :description_ja
end
end
Configure solrconfig.xml to enable Solr the language detection during indexing.
Adding the following updateRequestProcessorChain. Using “description_text” in langid.fl instead of “description” because Sunspot adds “_text” to field name.
<updateRequestProcessorChain name="langid">
<processor class="org.apache.solr.update.processor.LangDetectLanguageIdentifierUpdateProcessorFactory">
<bool name="langid">true</bool>
<str name="langid.fl">description_text</str>
<str name="langid.whitelist">en,ja</str>
<bool name="langid.map">true</bool>
<str name="langid.langField">language</str>
<str name="langid.fallback">en</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
I also added langid to the requestHandlers of “/update” and "/update/extract" as follows.
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">langid</str>
</lst>
</requestHandler>
<requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
<str name="lowernames">true</str>
<str name="uprefix">ignored_</str>
<str name="captureAttr">true</str>
<str name="fmap.a">links</str>
<str name="fmap.div">ignored_</str>
<str name="update.chain">langid</str>
</lst>
</requestHandler>
Check paths to the libraries
<lib dir="/path to/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="/path to/dist/" regex="solr-langid-\d.*\.jar" />
Configure schema.xml
Add fields for “description”. “_text_en” and “_text_jp” are for the outputs from the solr's language detection. “_en_text” and “_jp_text” for indexing/searching by sunspot.
<field name="name_text_en" type="text_en" indexed="false" stored="true"/>
<field name="name_en_text" type="text_en" indexed="true" stored="false"/>
<field name="name_text_ja" type="text_ja" indexed="false" stored="true"/>
<field name="name_ja_text" type="text_ja" indexed="true" stored="false"/>
For the detected language.
These copyfields are set for searching.
<copyField source="description_text_en" dest="description_en_text" />
<copyField source="description_text_ja" dest="description_ja_text" />
Need “text_en” and “text_ja” filedtypes in the schema.xml. I omit details configuration for them here, but use standard analyzers.
<fieldType name="text_ja" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="false">.....
<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">.....
Make indexing from sunspot
bundle exec rake sunspot:reindex
Search document – for test.
rails console
for English documents -
#search = Entry.search do
fulltext 'keyword_en' do
fields(:description_en)
end
end
for Japanese documents -
#search = Entry.search do
fulltext 'キーワード' do
fields(:description_ja)
end
end
#search.results
As you see that this is ad-hoc method and welcome any comments on it.

Solr: After reloading core config, admin panel doesn't respond

I'm running Solr 4.2 with sunspot in Rails, and have indexed about 6000 items.
Currently I'm playing around with the spellcheck feature. But everytime I make a change in the solrconfig.xml (like turning collation on and off), the admin panel from solr doesn't respond any more.
When I try to execute a query, the loading spinner shows up, and nothing happens. Same behaviour for other parts of the panel, like Core Admin or Statistics.
Restarting solr doesn't help. Reindexing the items doesn't helper neither. Only deleting the whole index files, restarting solr, and re-indexing all items does work; but that's a painful way to work.
So does anybody have a clue, what's happening here? Where could I start to debug? Is it related to the SpellChecker Component? Maybe I missed something here.
This is the part from the solrconfig.xml that I'm playing with:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">text_general</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">name_texts</str>
<str name="field">taxon_permalinks_sms</str>
<str name="classname">solr.DirectSolrSpellChecker</str>
<!-- the spellcheck distance measure used, the default is the internal levenshtein -->
<str name="distanceMeasure">internal</str>
<!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
<float name="accuracy">0.5</float>
<!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
<int name="maxEdits">2</int>
<!-- the minimum shared prefix when enumerating terms -->
<int name="minPrefix">1</int>
<!-- maximum number of inspections per result. -->
<int name="maxInspections">5</int>
<!-- minimum length of a query term to be considered for correction -->
<int name="minQueryLength">4</int>
<!-- maximum threshold of documents a query term can appear to be considered for correction -->
<float name="maxQueryFrequency">0.01</float>
<!-- uncomment this to require suggestions to occur in 1% of the documents
<float name="thresholdTokenFrequency">.01</float>
-->
</lst>
<!-- a spellchecker that can break or combine words. See "/spell" handler below for usage -->
<lst name="spellchecker">
<str name="name">wordbreak</str>
<str name="classname">solr.WordBreakSolrSpellChecker</str>
<str name="field">name_texts</str>
<str name="field">taxon_permalinks_sms</str>
<str name="combineWords">true</str>
<str name="breakWords">true</str>
<int name="maxChanges">5</int>
</lst>
</searchComponent>
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
<str name="spellcheck.dictionary">default</str>
<str name="spellcheck.dictionary">wordbreak</str>
<str name="spellcheck">on</str>
<str name="spellcheck.extendedResults">true</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.alternativeTermCount">5</str>
<str name="spellcheck.maxResultsForSuggest">5</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.collateExtendedResults">true</str>
<str name="spellcheck.maxCollationTries">10</str>
<str name="spellcheck.maxCollations">5</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
And btw: How can I check if my config for the different components is valid?
EDIT
When I try to open the search directly, e.g. curl or in my browser, it also hangs loading (e.g. calling http://localhost:8982/solr/core1/select?q=*%3A*&wt=xml&indent=true)
I found the solution here, if anyone is interested: solr - spellcheck causing Core Reload to hang
Turns out, it's a Solr bug, but there is an easy workaround. You have to delete the <str name="spellcheck.maxCollationTries">10</str> inside your request handler. This line causes the problem. If you really need this parameter, just append it to your URL and your safe.

How to resize the xib view of iphone application to fit to ipad in xcode

I created a simple calculator app in universal mode. I have two xib one for iphone and other for ipad. I created all my view design only in iphone, my ipad xib is blank. Now when I deployed my app for iphone in ipad, it comes in the size of iphone. I have choosen the autoresize option. Will I have to create same view of iphone in ipad xib for the correct display or is there any other way? This is how my app currently displays on ipad. I need it in a full screen mode.
EDIT: This is the sample source code of iphone xib. How should I modify this to fit for ipad?
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">10K549</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">933</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBUIView</string>
<string>IBUIBarButtonItem</string>
<string>IBProxyObject</string>
<string>IBUIToolbar</string>
<string>IBUITextField</string>
<string>IBUITextView</string>
<string>IBUITableView</string>
<string>IBUITableViewCell</string>
<string>IBUIButton</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="843779117">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="774585933">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUITextField" id="234836822">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{12, 48}, {286, 31}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="1066176330"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentVerticalAlignment">0</int>
<string key="IBUIText">0</string>
<int key="IBUIBorderStyle">3</int>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<int key="IBUITextAlignment">2</int>
<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
<float key="IBUIMinimumFontSize">17</float>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIKeyboardType">4</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription" id="1025764138">
<int key="type">1</int>
<double key="pointSize">14</double>
</object>
<object class="NSFont" key="IBUIFont" id="891898266">
<string key="NSName">Helvetica</string>
<double key="NSSize">14</double>
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUIButton" id="1066176330">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{41, 102}, {50, 50}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="182110945"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUITag">1</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">1</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="899681977">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
.
.
.
.
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">ViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="101.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="103.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="104.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="105.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="106.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="111.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="0.0" key="17.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="20.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="21.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="22.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="23.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="24.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="25.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="36.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="69.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="78.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="82.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="83.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="94.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">125</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">933</string>
</data>
</archive>
Right click on XIB.
Choose open as.
Choose Source code.
And in it modify following:
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{320, 480}</string>
<string>{480, 320}</string>
</object>
to:
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{768, 1024}</string>
<string>{1024, 768}</string>
</object>
That's it.
I suggest using AutoLayout. If you do your view with auto layout for iPhone it will look nearly the same on the iPad, just bigger. AutoLayout is pretty easy in XIBs.
The other possibility is to create a separate XIB for the iPad layout. If you do so just have a look at the other answers which describe how to do that easily.
You need to make two seprate xib and manage all buttons,textfiels and add all these in New Xib...
Way To Create Ipad Xib from iphone xib....
1)First copy iphone xib and paste just change the name like ~ipad.xib give and add it to the bundle
2)now you have an 2 xib 1 is for iphone and 1 is for ipad.
3)go to ipad xib right click on in it see open as -> open it in source code and then you have to find 320,480 value search that value in source code and change into
768,1024...
that's it do this way....
Yes!!! You have to create view for iPad also in other Xib file.
From Converting iPhone xib to iPad xib?
Refer Jag's answer..where he States that,
I was able to narrow it down to a few things, so here are the steps that worked for me:
1) Make a copy of the iPhone xib file and add it to your project
2) Right click the file (in xcode) and Open As > Source Code
3) The 2nd line should look like:
Replace with:
4) Search for "IBCocoaTouchFramework" and Replace all occurrences with "IBIPadFramework"
5) Save the file and Open As > Interface Builder - iOS
The file might still look like a regular iPhone xib, but for me, once I changed the Status Bar to "Black" in the Attributes inspector the rest of the xib just kind of "snapped" into an iPad xib
EDIT : You can also do in this way==>convert iphone App to IPad
1) Select the Universal option.
2) Transfer code from the existing iPhone project to the new project.
3) NOW,Make the xib files for iPad, and make the connections (IBOutlets).
Wherever you need platform specific features (eg. Popover, Split ViewController etc for iPad), put an IF statement to handle the device specific features.
In iPhone xib file change the target from iOS.CocoaTouch to iOS.CocoaTouch.iPad, and now if you open the file in interface builder, you will see settings for iPad.

Resources