Two UIPickerViews in one View - xcode4

I am new to Xcode. I am trying to build two UIPickerView in one view. The data in first UIPickerView is coming as desired but I am unable to get data in second UIPickerView. One picker has one component and another has two component.
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
if (pickerView == showData)
return 1;
else
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (pickerView == showData)
switch (tapButton) {
case 1:
return [countryData count];
break;
case 2:
return [serviceData count];
break;
case 3:
return [budgetData count];
break;
default:
return 0;
}
else {
if (component == 0)
return [hourTime count];
else
return [minuteTime count];
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
if (pickerView == showData)
switch(tapButton)
{
case 1:
return [countryData objectAtIndex:row];
break;
case 2:
return [serviceData objectAtIndex:row];
break;
case 3:
return [budgetData objectAtIndex:row];
break;
default:
return #"nothing";
}
else {
if (component == 0)
return [hourTime objectAtIndex:row];
else
return [minuteTime objectAtIndex:row];
}
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:
(NSInteger)component
{
if(component ==0)
{
return [serviceArray count];
}
else {
if ([Service isEqualToString:#"Hair"]) {
return [HairServices count];
}
if ([Service isEqualToString:#"Beauty"]) {
return [BeautyServices count];
}
if ([Service isEqualToString:#"Make Up"])
{
return [MakeUpServices count];
}
if ([Service isEqualToString:#"Eye lash extensions"])
{
return [EyelashServices count];
}
else {
return [HairServices count];
}
}
return 0;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row
{
[DisplayArray addObjectsFromArray:HairServices];
if(component ==0)
{
return [serviceArray objectAtIndex:row];
}
else {
if ([Service isEqualToString:#"Hair"]) {
// NSLog(#"DIS %#",DisplayArray);
[DisplayArray removeAllObjects];
[DisplayArray addObjectsFromArray:HairServices];
// NSLog(#" DISPLAY %#", DisplayArray);
return [DisplayArray objectAtIndex:row];
}
if ([Service isEqualToString:#"Beauty"]) {
[DisplayArray removeAllObjects];
[DisplayArray addObjectsFromArray:BeautyServices];
return [DisplayArray objectAtIndex:row]; }
if ([Service isEqualToString:#"Make Up"])
{
[DisplayArray removeAllObjects];
[DisplayArray addObjectsFromArray:MakeUpServices];
return [DisplayArray objectAtIndex:row];
}
if ([Service isEqualToString:#"Eye lash extensions"])
{
[DisplayArray removeAllObjects];
[DisplayArray addObjectsFromArray:EyelashServices];
return [DisplayArray objectAtIndex:row];
}
else {
return [HairServices objectAtIndex:row];
}
}
return 0;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
if (component == 0) {
Service=[[NSString alloc] initWithFormat:#"%#" , [serviceArray
objectAtIndex:row]];
[servicelistPicker reloadComponent:1];
}
else
{
NSLog(#" dis %#",DisplayArray);
if([DisplayArray count]>0)
{
SelectedServices =[NSString stringWithFormat:#"%#,",[DisplayArray
NSLog(#"%#",DisplayArray);
//[TempString appendString:SelectedServices];
ServicesTxt.text = SelectedServices;
ServicesTxt.font = [UIFont boldSystemFontOfSize:13];
}
}
}

Related

QEventDispatcherWin32::processEvents Logical issues

When see the qt source code(QEventDispatcherWin32::processEvents),i find a Logical issues.code as below,first it writes if(!haveMessage) next if(haveMessage),so code else if (...) and else{...} will never execute,what i think is right?
code as:
if (!haveMessage) {
// no message - check for signalled objects
for (int i = 0; i < (int)nCount; i++)
pHandles[i] = d->winEventNotifierList.at(i)->handle();
waitRet = MsgWaitForMultipleObjectsEx(nCount, pHandles, 0, QS_ALLINPUT, MWMO_ALERTABLE);
if ((haveMessage = (waitRet == WAIT_OBJECT_0 + nCount))) {
// a new message has arrived, process it
continue;
}
}
if (haveMessage) {
#ifdef Q_OS_WINCE
// WinCE doesn't support hooks at all, so we have to call this by hand :(
(void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM)&msg);
#endif
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
if (seenWM_QT_SENDPOSTEDEVENTS) {
// when calling processEvents() "manually", we only want to send posted
// events once
needWM_QT_SENDPOSTEDEVENTS = true;
continue;
}
seenWM_QT_SENDPOSTEDEVENTS = true;
}
else if (msg.message == WM_TIMER) {
// avoid live-lock by keeping track of the timers we've already sent
bool found = false;
for (int i = 0; !found && i < processedTimers.count(); ++i) {
const MSG processed = processedTimers.constData()[i];
found = (processed.wParam == msg.wParam && processed.hwnd == msg.hwnd && processed.lParam == msg.lParam);
}
if (found)
continue;
processedTimers.append(msg);
}
else if (msg.message == WM_QUIT) {
if (QCoreApplication::instance())
QCoreApplication::instance()->quit();
return false;
}
if (!filterEvent(&msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else if (waitRet >= WAIT_OBJECT_0 && waitRet < WAIT_OBJECT_0 + nCount) {
d->activateEventNotifier(d->winEventNotifierList.at(waitRet - WAIT_OBJECT_0));
}
else {
// nothing todo so break
break;
}

Sequence 1, 3, 8, 18, 38, 78 from a recursive function

I'm trying to write a recursive function in Java that would display the n element in a mathematical number sequence (1 3 8 18 38 78).
This is what I've managed to do so far:
public static int recfunc(int i) {
if(i==1) { return 1; }
if(i==2) { return 2+recfunc(i-1); }
if(i==3) { return 5+recfunc(i-1); }
if(i>3) { return ((2^(i-3))*5)+recfunc(3); }
return 0;
}
To calculate n(>3), you simply add together 2^(i-3) from each step(i>3) and then add 8 in the end. So, for the 6th element, you would have to do this calculation: 40 + 20 + 10 + 8 = 78.
The problem with the above code is that it successfully calculates the increase in a number between two n(s) and then ads 5 + 2 + 1 (8) to it, but it doesn't apply all the previous steps (20 + 10).
Update:
I'm getting somewhere, but it still doesn't do what it should.
public static int recfunc(int i, boolean param) {
if(param==false) {
if(i==1) { return 1; }
if(i==2) { return 2+recfunc(i-1, false); }
if(i==3) { return 5+recfunc(i-1, false); }
if(i>3) { param = true; }
}
if(param==true) {
if(i==4) {
return ((2^(i-3))*5)+recfunc(i-1, false); }
else {
return ((2^(i-3))*5)+recfunc(i-1, true); }
}
return 0;
}
The problem is with your power function. ^ in java does not mean to raise to a power. It means XOR.
You can use java's Math.pow()
int recfunc(int i) {
if(i==1) { return 1; }
if(i==2) { return 2+recfunc(i-1); }
if(i==3) { return 5+recfunc(i-1); }
if(i>3) {
return ((Math.pow(2,(i-3))*5)+recfunc(i-1));
}
return 0;
}
Hope this helps.
This code works fine now. Thanks for your help!
public static int recfunc(int i, boolean param) {
if(param==false) {
if(i==1) { return 1; }
if(i==2) { return 2+recfunc(i-1, false); }
if(i==3) { return 5+recfunc(i-1, false); }
if(i>3) { param = true; }
}
if(param==true) {
if(i==4) {
return (int)Math.pow(2.0f,(double)(i-3))*5+(int)(recfunc(i-1, false)); }
else {
return (int)Math.pow(2.0f,(double)(i-3))*5+(int)(recfunc(i-1, true)); }
}
return 0;
}

How to Explore Controls whit For in ASP.Net

First Excuse my English is bad!!!
I have A Web Form Where there are 120 RadioButtonList .I should monitored them
if (RadioButtonList1.SelectedValue == "1")
{
Response.Write("1");
}
else
{
Response.Write("0");
}
if (RadioButtonList2.SelectedValue == "1")
{
Response.Write("1");
}
else
{
Response.Write("0");
}
if (RadioButtonList3.SelectedValue == "1")
{
Response.Write("1");
}
else
{
Response.Write("0");
}
.
.
.
if (RadioButtonList120.SelectedValue == "1")
{
Response.Write("1");
}
else
{
Response.Write("0");
}
now i want do this whit For loop
Like this:
for (int i = 1; i <= 120; i++)
{
if (RadioButtonList[i].SelectedValue == "1")//Like Array :))
{
Response.Write("1");
}
else
{
Response.Write("0");
}
}
(This example is stupid.)
How did it do ?
again Excuse my English is bad!!!
string id="radiobuttonlist";
for(int i=1;i<121;i++)
{
id=id+i.ToString();
RadioButtonList rbl = (RadioButtonList)Page.FindControl(id);
if(rbl.SelectedValue == 1)
{
//do something
}
else
{
//do something
}
}

ASP.NET - What Characters does Server.HtmlEncode Encode into Named Character Entities

What characters does Server.HtmlEncode encode into named character entities?
So far I have only found < > & and " surely there must be more than this?
This is the code of HtmlEncode, so here you can see how they done it.
public static unsafe void HtmlEncode(string value, TextWriter output)
{
if (value != null)
{
if (output == null)
{
throw new ArgumentNullException("output");
}
int num = IndexOfHtmlEncodingChars(value, 0);
if (num == -1)
{
output.Write(value);
}
else
{
int num2 = value.Length - num;
fixed (char* str = ((char*) value))
{
char* chPtr = str;
char* chPtr2 = chPtr;
while (num-- > 0)
{
chPtr2++;
output.Write(chPtr2[0]);
}
while (num2-- > 0)
{
chPtr2++;
char ch = chPtr2[0];
if (ch <= '>')
{
switch (ch)
{
case '&':
{
output.Write("&");
continue;
}
case '\'':
{
output.Write("'");
continue;
}
case '"':
{
output.Write(""");
continue;
}
case '<':
{
output.Write("<");
continue;
}
case '>':
{
output.Write(">");
continue;
}
}
output.Write(ch);
continue;
}
if ((ch >= '\x00a0') && (ch < 'Ā'))
{
output.Write("&#");
output.Write(ch.ToString(NumberFormatInfo.InvariantInfo));
output.Write(';');
}
else
{
output.Write(ch);
}
}
}
}
}
}
.NET 4 and 4.5 encode single quotes also, which doesn't appear to be in the answer

How we Create Custom Decorator that can apply on file field and radio button selection

if We apply any custom decorator on radio button then it will be display on next line so how
we create such custom decorator that will display inline also same for file
checked=false;
function checkedAll (frm1) {
var aa= document.getElementById('frm1');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}
function check()
{
var aa= document.getElementById('frm1');
var flag;
for(var i =0; i < aa.elements.length; i++)
{
if(aa.elements[i].type=='checkbox')
{
if(aa.elements[i].checked && aa.elements[i].id !='checkall')
{
flag = true;
}
else if(!aa.elements[i].checked && aa.elements[i].id !='checkall')
{
flag = false;
break;
}
}
}
if(flag)
{
aa.elements.checkall.checked = true;
}
else
{
aa.elements.checkall.checked = false;
}
}
function notempty()
{
var flag=false;
var all ='';
var aa= document.getElementById('frm1');
for(var i =0; i < aa.elements.length; i++)
{
if(aa.elements[i].type=='checkbox')
{
if(aa.elements.checkall.checked)
{
flag = true;
all = 'd';
break;
}
else
{//alert(aa.elements[i].id);
if(aa.elements[i].checked && aa.elements[i].id !='checkall')
{
flag = true;
all += aa.elements[i].id.replace('check','') + '~';
}
}
}
}
if(!flag)
{
alert("please select a contact to delete..");
return false;
}
if(flag)
{
//alert(all);
document.location.href= '/member/public/index/delete?all='+all;
return false;
}
}
onclick='checkedAll(frm1);'>
escape($data->id);?>"
onclick="check();">
10px;" onclick="return notempty();" value="DELETE" />

Resources